{"id":9462,"date":"2016-02-18T09:24:19","date_gmt":"2016-02-18T01:24:19","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=9462"},"modified":"2024-07-04T16:09:42","modified_gmt":"2024-07-04T08:09:42","slug":"eval","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/eval\/","title":{"rendered":"Eval()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>Eval(String[, ParamsArray])<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Evaluates the specified expression.\u00a0Optionally it can also override the value of <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/calculation-syntax\/#Context_Parameters\">context parameters<\/a> for the duration of the evaluation.<\/p>\n<p class=\"intro-text\">Behaves in exactly the same way as the EvalExp() function, except that the first parameter\u2019s type is a single value string<i>\u00a0<\/i>and not an expression.\u00a0<\/p>\n<p class=\"left-bar-yellow\"><strong>Use caution when nesting the Eval() functions, as they can quickly become complicated and difficult to troubleshoot.<\/strong><\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><strong>String<\/strong>: The string to be evaluated.<br \/>\nBehaviour: Required<br \/>\nDimension: SingleValue <br \/>\n<em>Note: Also supports a single string that contains an expression which returns a multi-collection variable, but a multi-collection of string is not supported.<\/em><br \/>\nValid\u00a0data types: String<\/p>\n<p class=\"intro-text\">Note: This string will be treated as an expression and sent to IFS OI Server to be resolved. The function will return the result of the expression.<\/p>\n<p class=\"intro-text\"><strong>ParamsArray<\/strong>:\u00a0The context parameters to be used to override the default context parameters of the expression.<br \/>\nBehaviour: Optional [0..n]<br \/>\nDimension: Collection, SingleValue, Matrix<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration, Error<\/p>\n<p class=\"intro-text\">Note:\u00a0These parameters must be specified in pairs. The first parameter must be the name of a single value context parameter and the second parameter must be the value of it. <br \/>\nE.g. <span class=\"code-fragment\">Eval(\"{myTag}\", \"sampleMethod\", \"Raw\")<\/span>. This will evaluate the \"{myTag}\" string\u00a0with the sample method set to \"Raw\" in the string\u00a0context. Note the use of {} around the tag name.<\/p>\n<p class=\"left-bar\"><a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/calculation-syntax\/#Data_Type\">How to format data types<\/a><\/p>\n<h2>When to use<\/h2>\n<p class=\"intro-text\">Both Eval() and EvalExp() can be used for evaluating expressions with overridden context parameters.\u00a0The difference is that the first parameter of Eval() is a string while the first parameter of EvalExp() is an expression.<\/p>\n<p class=\"intro-text\">Here is an example showing the difference (without using context parameters, for simplicity):<\/p>\n<p class=\"intro-text\"><span class=\"code-fragment\">Eval(\"1 + 2\")<\/span> -&gt; returns 3<br \/>\n<span class=\"code-fragment\">EvalExp(1 + 2)<\/span> -&gt; returns 3<\/p>\n<p class=\"intro-text\">The most obvious difference is that Eval() expects a string and therefore the first parameter must be wrapped in quotation marks.\u00a0As EvalExp() expects an expression parameter, it doesn\u2019t require quotes.<\/p>\n<p class=\"intro-text\">This means that you can use Eval() to evaluate a string which is generated and not hard-coded (as if it was an expression).<\/p>\n<p class=\"intro-text\">You should use Eval() if you have a string (which is often generated as the result of a sub-expression) and you want to treat that as an expression and evaluate it with or without overridden context parameters. Otherwise, use EvalExp().<\/p>\n<h2>Examples<\/h2>\n<p class=\"intro-text\">Expression:\u00a0<span class=\"code-fragment\">Eval(\"1+2\")<\/span><br \/>\nExpected result:\u00a03<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">Eval(\"{\" + entity + \":attribute}\")<\/span><br \/>\nExpected result: Fetches the <em>entity:attribute<\/em> attribute value and return its value as a collection variable<\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>Eval() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed String parameter to support an expression containing a MultiCollection value.<\/li>\n<\/ul>\n<\/li>\n<li>Eval() 4.0\n<ul class=\"intro-text\">\n<li>Initial version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Use Eval() to evaluate an expression, or to override the value of context parameters for the duration of the evaluation.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/eval\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":9587,"parent":3650,"menu_order":116,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100],"class_list":["post-9462","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","Version-4-0","Version-4-6-5","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/comments?post=9462"}],"version-history":[{"count":8,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9462\/revisions"}],"predecessor-version":[{"id":67796,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/9462\/revisions\/67796"}],"up":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/3650"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media\/9587"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=9462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=9462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=9462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}