Business Rule - Comparing run time prompts in calculation manager rules
Hi All,
This post is about comparing the run time prompts in business rule. Recently, one of my colleague asked me about the question on how to compare the run time prompts in business rule, so thought of creating a post. Another reason is I have seen many people using the below approach to compare the run time prompt value, so this even made me think to add this post and explain them the issue with below approach.
if({vMonth} == "Jan")
Below is the smartview data set for our test
Below is the script which we will execute to test the above approach; {vMonth} value selected as "Apr" while running the script.
Expected result would be
Apr = 1144 * 497 = 56568
Jan, Feb, Mar = 100
Now lets see the result;
Result is not as expected !!.
What did we do wrong;
The answer is {vMonth} == "Apr", compares the value #Missing = #Missing; which is true for all the months and hence it calculated the values for all the months instead of assigning value 100.
Another twist in the script to prove the above point.
Below is the data set;
Below is the script to be executed.
Result is as below;
Ohh!! it only worked for Mar this time :-o y !!
Again the script compared the value; 10 == 10 which was true for March.
So how do we compare the run time prompts?
The answer is @ISMBR("Apr") & keeping the run time prompt in FIX.
Our script would look like as below;
Result;
One can also use;
@HspStringCompare(@Name({vMonth}), @Name("Apr")) & keeping the run time prompt in FIX.
Hope you like it and it would have cleared all the doubts ;
This post is about comparing the run time prompts in business rule. Recently, one of my colleague asked me about the question on how to compare the run time prompts in business rule, so thought of creating a post. Another reason is I have seen many people using the below approach to compare the run time prompt value, so this even made me think to add this post and explain them the issue with below approach.
if({vMonth} == "Jan")
Below is the smartview data set for our test
Below is the script which we will execute to test the above approach; {vMonth} value selected as "Apr" while running the script.
Expected result would be
Apr = 1144 * 497 = 56568
Jan, Feb, Mar = 100
Now lets see the result;
Result is not as expected !!.
What did we do wrong;
The answer is {vMonth} == "Apr", compares the value #Missing = #Missing; which is true for all the months and hence it calculated the values for all the months instead of assigning value 100.
Another twist in the script to prove the above point.
Below is the data set;
Below is the script to be executed.
Result is as below;
Ohh!! it only worked for Mar this time :-o y !!
Again the script compared the value; 10 == 10 which was true for March.
So how do we compare the run time prompts?
The answer is @ISMBR("Apr") & keeping the run time prompt in FIX.
Our script would look like as below;
Result;
One can also use;
@HspStringCompare(@Name({vMonth}), @Name("Apr")) & keeping the run time prompt in FIX.
Hope you like it and it would have cleared all the doubts ;
Thanks it was really helpful
ReplyDelete:)
DeleteAmazing!!! You are a rockstar!!
ReplyDeleteJust what I was looking for! Thank you for this!
ReplyDelete:)
DeleteNice Explanation
Delete