{"id":28029,"date":"2017-06-16T15:06:54","date_gmt":"2017-06-16T07:06:54","guid":{"rendered":"http:\/\/localhost\/help\/?page_id=28029"},"modified":"2024-08-15T10:31:30","modified_gmt":"2024-08-15T02:31:30","slug":"replacevalues","status":"publish","type":"page","link":"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/replacevalues\/","title":{"rendered":"ReplaceValues()"},"content":{"rendered":"\n<h2>Format<\/h2>\n<p class=\"intro-text\"><strong>ReplaceValues(Source, Replace, Replacement)<\/strong><\/p>\n<h2>Returns<\/h2>\n<p class=\"intro-text\">Replaces the values in the first argument it is passed.<\/p>\n<h2>Inputs<\/h2>\n<p class=\"intro-text\"><b>Source: <\/b>The argument in which values will be replaced.<br \/>\nBehaviour: Required<br \/>\nDimensions: Collection, SingleValue, MultiCollection<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/p>\n<p class=\"intro-text\"><b>Replace: <\/b>The value that has to be replaced. This must be the same data type as the Source value.<br \/>\nBehaviour: Required<br \/>\nDimensions: SingleValue<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/p>\n<p class=\"intro-text\"><b>Replacement: <\/b>The replacement value for all matched values in the source expression. For single values, this may be of a different data type to the Source value. For collections, this should be the same data type as the Source value.<br \/>\nBehaviour: Required<br \/>\nDimensions: SingleValue<br \/>\nValid data types: Null, Boolean, DateTime, Decimal, Integer, String, Duration<\/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><span id=\"Error_Conditions\">Error Conditions<\/span><\/h2>\n<p class=\"intro-text\">An error will be thrown if:<\/p>\n<ul class=\"intro-text\">\n<li>A tag or entity supplied as an argument does not exist.<\/li>\n<li>The data type of the first two arguments are not the same.\n<ul class=\"intro-text\">\n<li>Error example: <span class=\"code-fragment\">The value cannot be converted from error to boolean.<\/span><\/li>\n<\/ul>\n<\/li>\n<li>The data type of the Replacement is not compatible with the data type of the Source (applies to collections).\n<ul class=\"intro-text\">\n<li>Error example: <span class=\"code-fragment\">The type of the supplied VariableValue (\"String\") is not compatible with the type of the VariableValueCollection (\"Integer\").<\/span><\/li>\n<\/ul>\n<\/li>\n<li>The data type of a parameter is not valid.<\/li>\n<\/ul>\n<h2>Examples<\/h2>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues(2 + 3, 5, 6)<\/span><br \/>\nResult: <span style=\"color: #0000ff;\">6<\/span><\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues({Tag1}, 0, 1)<\/span><br \/>\nResult: The value of the <em>Tag1<\/em> tag with every <em>0<\/em> value replaced with an integer value of <em>1<\/em>.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues(Boolean(0), False, True)<\/span><br \/>\nResult: Replaces the Boolean <em>False<\/em> value, with a Boolean value of <em>True<\/em>.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues(DateTime(12), DateTime(12), 13)<\/span><br \/>\nResult: Replaces the DateTime value of <em>12<\/em>, with an integer value of <i>13<\/i>.<\/p>\n<p class=\"left-bar\">Tip: If you have access to the sample data, try running the following examples using the\u00a0<a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/configuring-your-system\/creating-a-calculation\/using-the-calculation-tester\/\">calculation tester<\/a>.\u00a0<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues({Archer[Oil Producing Well]:Status!Actual}, 0, 3)<\/span><br \/>\nResult: The value of\u00a0the\u00a0<em>Archer[Oil Producing Well]:Status!Actual<\/em> attribute,\u00a0with every <em>0<\/em> value replaced with an integer of 3.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues({ReturnNull}, Null, 1)<\/span><br \/>\nResult: The value of the\u00a0<em>ReturnNull<\/em>\u00a0calculation, with every null value replaced with an integer value of <em>1<\/em>. This is different from <a href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/replacenull\/\">ReplaceNull<\/a>(), which\u00a0replaces null values in a collection with the last known value.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues({OperatingStatus}, 0, \"test\")<\/span><br \/>\nResult: This will <span style=\"color: #ff0000;\">fail<\/span> because you cannot put a string value into an integer collection.<\/p>\n<p class=\"intro-text\">Expression: <span class=\"code-fragment\">ReplaceValues({OperatingStatus}, 0, null)<\/span><br \/>\nResult: The value of the <i>OperatingStatus\u00a0<\/i>calculation, with every 0 integer value replaced with a <em>null<\/em> value. This is allowed because nulls and integers can be mixed in a collection. Errors and integers can also be mixed in a collection.<\/p>\n<h2><span id=\"Release_History\">Release History<\/span><\/h2>\n<ul class=\"intro-text\">\n<li>ReplaceValues() 4.6.5\n<ul class=\"intro-text\">\n<li>Changed Source parameter to support MultiCollection values.<\/li>\n<\/ul>\n<\/li>\n<li>ReplaceValues() 4.5.1\n<ul class=\"intro-text\">\n<li>Initial version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Replaces the values in a variable.<\/p>\n<p class=\"continue-reading-button\"> <a class=\"continue-reading-link\" href=\"https:\/\/oihelp.corporate.ifs.com\/help\/p2-server\/calculations\/replacevalues\/\">Read more<i class=\"crycon-right-dir\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":28082,"parent":3650,"menu_order":173,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[9],"tags":[100],"class_list":["post-28029","page","type-page","status-publish","has-post-thumbnail","hentry","category-tech-ref","tag-calculations","Version-4-5-1","Version-4-6-5","Product-srv"],"_links":{"self":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28029","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=28029"}],"version-history":[{"count":2,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28029\/revisions"}],"predecessor-version":[{"id":64755,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/pages\/28029\/revisions\/64755"}],"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\/28082"}],"wp:attachment":[{"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/media?parent=28029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/categories?post=28029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oihelp.corporate.ifs.com\/help\/wp-json\/wp\/v2\/tags?post=28029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}