Skip to main content

Posts

Showing posts from 2017

Force recall a Salesforce approval process

Non-submitter and non-administrator approval recallSalesforce lacks the functionality to recall an in-flight approval process for anyone other than the original submitter or a system administrator. For our latest client this posed a problem as their specific business needs required the ability to recall an approval one step back in a multi person process, and giving the approvers administrative permissions posed an unacceptable security risk. Thus until Salesforce implements this idea (please upvote) to extend recalling to record owners, below approach workaround will accomplish approval recall without compromising security - albeit in an interesting way.setup an email service that runs in elevated privileges and recalls force recall an approvalprovide normal users the ability to execute an Apex method that internally emails that serviceReference setupBelow are the relevant bits extracted from a working solution, leverage and adapt to your own unique solution.Apex Class global virtua…

First error: Process failed. First exception on row 0; first error: INVALID_OPERATION, Illegal transition type: []

Approving a record through APEX errorSearched return no relevant results to the issue I encountered. I encountered this when writing a schedulable class and thought it was due to SF restriction inside the limited context of the scheduler; so posting this in hopes it saves others some frustration and time.The solutionCheck the spelling when specifying the action (see Docs here). In my case I had Approved instead of Approve, allowed options are Approve, Removed, and Reject. ... Approval.ProcessWorkitemRequest oPWR = new Approval.ProcessWorkitemRequest(); oPWR.setComments('Auto approved through JobId: \'' + oBatchableContext.getJobId() + '\''); oPWR.setAction('Approve'); // allowed choices are 'Approve`, `Removed`, `Reject`. oPWR.setWorkItemId(oWorkItemCurrent.ID); Approval.ProcessResult oPR = Approval.process(oPWR); ... If this has helped you feel free to comment or follow me on twitter @danielsokolows.

Selecting Indvidiual Custom Labels in Eclipse Force.com IDE

Workaround for managing individual custom labels in Eclipse Force.com IDEUnfortunately the Force.com IDE does not yet support individual custom label selection even though the UI does. There is a bug/issue filled so please upvote it at this link Selection of individual `CustomLabels` not working There is a workaround however. One must manually update the `package.xml` and specify the metadata member `CustomLabel` (no s at the end) and the individual labels like so. Also ensure you don't have the labels node selected through the Eclipse Force.com IDE UI, that is there should not be an entry in your `package.xml` for member `CustomLabels`. One annoying caveat of this is to edit `CustomeLabels.labels` you must be in offline ('Right click root project > Force.com > Work Offline') mode otherwise it get's still refreshed from the server. <types> <members>Label_1</members> <members>Label_2</members> <members&g…

MQL5 indicator artifacts issue

MQL5 indicator buffer random valuesDuring my coding of an indicator random values would end up in the index buffer if one would switch time frames. It took me a few hours to figure out that if I didn't explicitly set an empty value this would cause this to happen - so the solution is to always set a value during your OnCalculate() loop both for your empty bars and not. /* OnCalculate =========== Called only in custom indicators when it's necessary to calculate the indicator values by the Calculate event. */ int OnCalculate(const int iRatesTotal, const int iPreviousCalculated ,const datetime &time[] ,const double &aOpen[] ,const double &aHigh[] ,const double &aLow[] ,const double &aClose[] ,const long &tick_volume[] ,const long &volume[] ,const int &spread[]) { Print(">>> OnCalculate(): `iRatesTotal=" + iRatesTotal + "`, `iPreviousCalculated=" + iPreviousCalculated + "`"); //int iStart…

A review of my one month FOREX trading experience

In Charts and TablesMy first month trading FOREX trading is now complete and as expected (but definitely not wanted) my account balance has gone down 52%. I have done a total 115 trades which equates to about 28 trades per week.Trade History export to CSV MetaTrader must have been designed by geeks for geeks as there is no export to CSV/Excell. Fortunately I am such aforementioned geek and created a script for this purpose. On the bright side is I expected to start learning MQL at some point so this started that process. You can find my script at this link: MetaTrader Export Trade History to CSV.Lossing vs Winning Trades I did really great in the first week, perhaps it was luck perhaps it was new trader confidence. Looking back at the trades I seldom had a stop loss, had a generous stop loss in place, or kept adjusting it, and I recall leaving the trades alone then coming back to them seeing profits and just setting a trailing stop loss; I can possibly confirm this by looking how the or…

Least Correlated Forex Currency Pairs

Minimizing risk trough Un-correlationThe number of possible major/minor currency is large and trading currencies that are correlated logically increases risk. My Google search for least correlated Forex pairs came up empty so I decided to run the analysis myself. Using information from this list on Oanda I created a JS script that would loop through the table entires and return the least correlated pairs based on the 1 year value. Major Currencies Max correlation between -0.50 and 0.50. ["AUD/JPY", "AUD/USD", "EUR/AUD"] Major + Minor Currencies Max correlation between -0.60 and 0.60, with preference to try to keep major currencies in final set ["AUD/CAD", "AUD/CHF", "AUD/HKD", "AUD/JPY", "EUR/GBP", "EUR/SEK", "NZD/CAD", "SGD/CHF", "USD/SAR"] You may want to run the below snippet and adjust aPAIRS_TO_TRY_FIRST and nMAX_ABSOLUTE_CORRELATION with your own needs. Feel …