Changes

Jump to: navigation, search

The Musings of Chin - Correct Variable Processor Use

115 bytes added, 18:16, 16 July 2013
no edit summary
The Variable Processor is the functionality built into SmartSimple used to pre-process and dynamically replace various values throughout the system with context to the current user or the object being viewed. While the Variable Processor is a very powerful and useful tool, when carrying out any configuration one must understand the basics behind how it functions.
It is easy to make mistakes that lead to various degrees of undesired behaviour, and some of these self-imposed issues can actually be very subtle and hard to notice as well. The good news is that these issues are also easily avoided by keeping the following best practices in mind:.
In general, any time that you retrieve a variable for use in a calculation, evaluation, or assignment to another field , you need to always encapsulate it within double quotes.
== In Template Formulas ==
'''Problem 1''':
''@level1.name@=@level1.owner.firstname@ @level1.owner.lastname@;''
Reason:
'''Problem 2''':
''@level1.name@='@level1.owner.firstname@ @level1.owner.lastname@';''
Reason:
Solution:
''@level1.name@="@level1.owner.firstname@ @level1.owner.lastname@";''
Always use double quotes around strings to be safe.
'''Problem 1''':
''frm.cf_@customfield.id@.value="";''
Reason:
Solution:
''document.getElementById("cf_@customfield.id@");''
'''Problem 2''':
''var oppid=@opportunityid@;''
Reason:
Solution:
''var oppid="@opportunityid@";''
== In Visibility Conditions ==
'''Problem 1''':
''@opportunityid@>0''
Reason:
Solution:
''"@opportunityid@">0''
Note: For this particular example, there is a check box setting within the custom field configuration that allows you to hide fields on new objects until the object is saved at least once.
'''Problem 1''':
''@ReportProperty(12345,recordcount)@ + @custom number@''
Reason:
Solution:
''"@ReportProperty(12345,recordcount)@"*1 + "@custom number@"*1''
The ''*1 '' is used to explicitly cast the result into a numeric value. This is needed in the case that perhaps your ''@custom number@ '' contains an alphabetic character, the ''*1 '' will convert it to a 0. If for some reason you use a @ReportProperty()@ that returns blank, ''""*1 '' will also convert to a 0.
'''Problem 2''':
2) When the variable value you are retrieving contains double quotes within itself you will need to escape these, or encapsulate the variable within single quotes if you are sure the variable value does not contain single quotes within.
 
==See Also==
* [[sslogic]]
* [[sscalculation]]
* [[inRole]]
[[Category:Chin’s Musings]] [[Category:Variables]]
8,849
edits

Navigation menu