Skip to Content
author's profile photo Former Member
Former Member

Comparing two dates using Rules in Syclo Agentry Application (SAP Work Manager)

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

1.png (27.2 kB)
2.png (41.7 kB)
3.png (39.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 30, 2014 at 11:44 AM

    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!


    5.png (32.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.