on 04-29-2014 8:44 PM
Hello Experts,
I am trying to compare two dates using Rules under a particular field in SAP WM application.
I am trying to compare a date (coming from SAP ECC, stored under the object property) and the System Date (using Date function).
I couldn't find a direct function to compare dates, nor the GT(greater than) functions works here.
I am trying to display a particular image, based on the condition if the duedate has passed already.
My rule structure is as follows.
The first parameter to the JavaScript logic block is the "DueDate" property from the workorder object.
I am using the System->Date function as follows, this is used as the second parameter to the JavaScript.
The JavaScript block just compares the dates ( the string can now be compared directly in the MM-DD-YYYY format).
Unfortunately, This rule is not working correctly.
Can you please suggest what am I missing here?
Thanks for the help!
Best Regards,
Arihant Kothari
Update:
Here is the updated rule.
I was able to debug the rule and below is the log for the same.
2014/04/30 16:06:22.996: | + Property=:>"DueDate" Property | |
2014/04/30 16:06:22.996: | Result<String>= '2014-03-17' | |
2014/04/30 16:06:22.996: | + Function=@DATE | |
2014/04/30 16:06:22.996: | + ConstantTerm= | |
2014/04/30 16:06:22.996: | Result<Property>= "" | |
2014/04/30 16:06:22.996: | + ConstantTerm= | |
2014/04/30 16:06:22.996: | Result<String>= '' | |
2014/04/30 16:06:22.996: | Result<String>= '4/30/2014' | |
2014/04/30 16:06:22.996: | JAVASCRIPT ERROR - Microsoft JScript compilation error: 'return' statement outside of function. Line #4 (1): return true; | |
2014/04/30 16:06:22.996: | Result<Boolean>= false | |
2014/04/30 16:06:22.996: | + ConstantTerm=Blank24x24x1 | |
2014/04/30 16:06:22.996: | Result<String>= 'Blank24x24x1' | |
2014/04/30 16:06:22.997: | Result<String>= 'Blank24x24x1' |
2014/04/30 16:06:22.997: Result<String>= 'Blank24x24x1'
2014/04/30 16:06:22.998: + Rule=ZImageWorkOrderDueDateWarning_iPad
2014/04/30 16:06:22.998: + Function=@IF
2014/04/30 16:06:22.998: | + Function=@JAVASCRIPT |
2014/04/30 16:06:22.998: | + JavaScriptTerm=if (argv[0] < argv[1]) |
{
return true;
}
2014/04/30 16:06:22.998: | : 4 lines, 3 non-printing characters, 61 total characters |
Result<String>= 'if (argv[0] < argv[1])
{
return true;
}
Here, the Date function is returning the date in "m/dd/yyyy" format in-spite of the format token "yyyy-MM-dd" . Also, can you please point out the error with the JavaScript block?
I see that I cannot use a return statement there under JavaScript text. In that case, How can I return the comparison result from JavaScript so that it can be used as the condition under the upper "IF" block?
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Arihant,
What data type is your DueDate property? If it is an Agentry date, then this is easy. If it is a string, then it is more difficult. Make it an actual Agentry date if you can. Agentry date properties are internally just numbers, so they can be compared with the LT, GT math functions. No javascript required. You can do something like this:
IF
GT
DueDate Property
DATE
DATE
DueDateIsGreaterImage
DueDateIsLessThanOrEqualImage
The Date function above should return the current date when DATE is passed as the parameter.
Jason Latko - Senior Product Developer at SAP
Hi Jason,
Thank for looking into this issue.
The DueDate property is from the standard WorkOrder object and it is of type String.
I was trying to use JavaScript, but ran into two issues here.
1) Even after formatting the Date function (as in the above screenshots, to yyyy-mm-dd), the log shows that the date is being formatted as m/dd/yyyy.
2) I can't use RETURN statement from the javaScript block. How can I overcome this issue?
Best,
Arihant
Hello Jason,
I was successfully able to compare the dates using GT, after changing the property to type "Date" from "String".
Currently, I have a field "DueDateIcon" on a "List Screen" for an iPad.
I have setup the rule against "Icon Image" setting on this field. Currently hardcoded in the screenshot.
the rule is returning the value as "Circle24x24x1", but the list is not able to display this image.
Is this the correct way of displaying an image under a list field on the list screen?
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.