You need to sign in to do that
Don't have an account?
kb15
Parsing and evaluating the expression
Need to parse and evaluate the expression entered via InputText, user may enter text as below into the given text Field
Opportunity.Amount * 1.5
It should evaluate the value of Opportunity.Amount and also it should perform arithmatic operation.
Any help will be appreciated.
You can use <apex:variable> with your code.
Refer following example
http://visualforcemadeeasy.blogspot.com/2010/04/how-to-use-apex-variable-for-total.html
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Thanks for the inputs, but really not sure how this will be helpful in the current scenario
Basically we need to perform arithmatic operation in the apex class or Trigger. So need to evaluate the string to perform the mathematical operation and give the result. Similar to JS function eval. I could have directly used this js function eval but this is to be done on the apex/trigger side. So if the user enters - Opportunity.Amount (sObject.Field), this can be evaluated at apex side.
Ohh my bad, You want to get the value of String and do the operation. If so, you need to refer this link and solve your problem
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Hi, did you find any solution for this?
We also have a similar requirement - need to evaluate a string expression from a trigger. Please let me know is there a solution or any workarounds for this.
Thanks,
Sorna
Hi
We achieved this by sending the string content to dot NET program which evaluated the actual value + arithmetic operation and returned the result.
You can try this by either .NET or Java.
Let me know if this helps you?
Thanks
Thanks, Chamil!
String.valueOf( was exactly what I needed.
:}