Hi,
I am taking the service name from drop down field from interface and mapping it to following variable.
After that I am uploading excel as below:
Following is the rule I am using in script task and saving its value into Boolean type variable 'flag'.
My requirement is if pv!Service_name=pv!cdt.srvc_nm then it should go to XOR path otherwise send email path.
if I change the value in excel rows the flow is not going in appropriate way.
Thanks,
Kiran
Discussion posts and replies are publicly visible
Unknown said:Following is the rule I am using in script task and saving its value into Boolean type variable 'flag'
TIP: In this code block, you can eliminate the if() condition as the contains() function will give you a boolean value itself.
Now to debug the problem, did you check if both the variables are populating correctly in the process details of the instance? If yes, then try to wrap the parameters of contains() function in touniformstring() and tostring() respectively. That should solve the problem.
Hi Harshit,
see this are my pv values. The flow should go to copy of send email but it is going to XOR as mentioned above
Is there a specific reason for copying the data into a local variable using foreach()?
In the data you shared, I see an "a" at the end of the first value. Could it be that there is a space before or after the second one? In cases like this, I recommend to first try to get working code in a separate expression. Once I understand the what is going on, I put it into process. This makes debugging way easier.
Hi Stefan,
its random value other than PV! service_name for which I am checking the condition.
If PV! service name does not match with any value of pv!cdt.srvc_nm then the flag should be false and it should go to copy of send email otherwise it should go to next node(which is XOR)
I fully understand what you are trying to do.
1) Why do you copy the data?
2) Why the if()
And, when none of the values matches your string, then the XOR is working as expected. First, make sure that your logic works, then check your values and finally put it into the process.
contains() will return true if ANY items in the array match. thus your pv!flag will be set to TRUE, and the "XOR" path will be executed.
I have 2 scenarios.
when I give service_name from the dropdown that value will be searched in my uploaded file.
Scenario1:If the dropdown value matches the service name in the excel then it should go to next XOR gateway.
scenario2: If the dropdown value does not matches with service name in the excel then it should go to send email node.
For this question I am giving manual values to excel file uploaded. My dropdown points to CONT-ALOC value, this value is searched in my multiple type of pv!cdt.
Unknown said:Why do you copy the data?
This can be done using contains also, but just for testing I am putting it in a flag variable to check the value.
Unknown said:hy the if()
Kindly, tell me what should I write in the XOR condition.
You have multiple values in your excel file. Does your logic apply to each individually, or to all at once?
I was referring to your code snippet from above:
1) What is the purpose of copying the data into a local using a foreach?
2) contains() returns a boolean value. What is the purpose of the if()?
Unknown said:2) contains() returns a boolean value. What is the purpose of the if()?
In fairness, i find myself sometimes using this/similar style of mildly-redundant if() statement, if only to cement (even if for no other reason than readability later) what the positive and negative outcomes are intended to be. But you're right that it's redundant and you're right that folks should learn the concepts behind how and why this is true.
I agree, and I even use this in case I have to implement a more complex logic. When doing a code review, I accept this only in case of an explicit design decision.