salesforce - Is it possible to convert a string in to a programming statement in apex? -


public string var='public string var1=\'some text\'; ' ; 

i require string inside var execute , create variable "var1" , assigned value "some text".

is possible this? if yes how possible?

yes, sort of. possible mimic javascript eval() in apex making callout executeanonymous api method.

there 2 common ways can response executeanonymous.

  1. throw deliberate exception @ end of execute , include response. kevin covers approach in eval() in apex. secure dynamic code evaluation on salesforce1 platform.
  2. i used variation of approach returned response via debug log rather intentional exception. see adding eval() support apex.

using example apex like:

public string var = soapsforcecom200608apex.evalstring(                 'string var1=\'some text\'; system.debug(logginglevel.error, var1);'); 

you might not able perform callout during member initialisation or in constructor.

incidentally, salesforce stackexchange site great place ask salesforce specific questions.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -