Policy Automation for B2C Service

Get Involved. Join the Conversation.

Topic

    Shyam Sudheesaraj
    Number of days in the monthAnswered
    Topic posted January 10, 2017 by Shyam SudheesarajRed Ribbon: 250+ Points 
    192 Views, 7 Comments
    Title:
    Number of days in the month
    Content:

    Hi,

    I am trying to learn and try out the examples mentioned in OPA tutorials. In 'Number of days in the month" example, I thought user input is not required and the total number of days in the current month will be directly displayed on the screen.

    This is the code in that example and entire logic's input is based on 'the date', I fail to understand why when executing this in debug mode, I have been prompted for 'what is the start of the month' and 'what is the start of next month'.

    the number of days in the month = DayDifference(the start of the month, the start of next month)

    the start of the month = MakeDate(the year, the month, 1)

    the start of next month =  AddMonths(the start of the month, 1)

    the year = ExtractYear(the date)

    the month = ExtractMonth(the date)

     

    Version:
    OPA August 2016
    Image:
    Code Snippet:

    Best Comment

    Anuj Behl

    Hi Shyam,

    I see that these 2 attributes are coming as Input attributes instead of being Inferable attributes. Can you please paste a screenshot of the Data tab with the attributes list and make sure those 2 attributes do not have role of Input in Data tab.

    -Anuj

    Comment

     

    • Anuj Behl

      Hi Shyam,

      I see that these 2 attributes are coming as Input attributes instead of being Inferable attributes. Can you please paste a screenshot of the Data tab with the attributes list and make sure those 2 attributes do not have role of Input in Data tab.

      -Anuj

    • Shyam Sudheesaraj

      Hi Anuj,

      ​Thanks for responding, I checked my data tab and they are of input type. How do I change them from input variable to inferable?

      Please find the screenshot here 

      Cheers,

      Shyam

    • Matt Sevin

      The example referenced does require "the date" as an input on a screen.  You could reference "the current date" (built-in reference to the system date) instead of "the date".

    • Shyam Sudheesaraj

      Hi Matt,

      Thanks for responding, I have changed the code to reference 'the current date' instead of 'the date', I can still see 'Role' for attributes 'the start of next month' and 'the start of the month' under Data Tab as 'input'. What are the steps required so that I won't be prompted for entering the dates?

      the number of days in the month = DayDifference(the start of the month, the start of next month)

      the start of the month = MakeDate(the year, the month, 1)

      the start of next month =  AddMonths(the start of the month, 1)

      the year = ExtractYear(the current date)

      the month = ExtractMonth(the current date)

       

      Cheers,

      Shyam

    • Matt Sevin

      You should be seeing all the attributes (input and inferred) in the data tab of the project.  Attributes recognized in the rule document should also be underlined as shown in the first line of the image you included in the original post.  Note that the other lines are not showing the attribute as recognized.  Open your rule document and verify everything is correct there.  Then check the data tab for the project.  If you are still having a problem, please attach the rule document and a screenshot of the data tab entries. 

    • Shyam Sudheesaraj

      Thanks Matt, I could fix it this time. I deleted the existing rule doc and created a new one with the below content. In my previous rule doc, only the first rule had an underline, fixed it by entering each rule via rule assistant. Now I get to see the number of days in the month without being prompted for dates.

      the number of days in the month = DayDifference(the start of the month, the start of next month)

      the start of the month = MakeDate(the year, the month, 1)

      the start of next month =  AddMonths(the start of the month, 1)

      the year = ExtractYear(the current date)

      the month = ExtractMonth(the current date)

      Cheers,

      Shyam 

    • Sue Novak

      I have updated the "Calculate the number of days in a month" topic in the OPA Documentation Library to make it much clearer how these rules work. See:

      http://documentation.custhelp.com/euf/assets/devdocs/unversioned/PolicyAutomation/en/Default.htm#Guides/Policy_Modeling_User_Guide/Work_with_rules/Create_rules/Write_rules_using_dates_and_times/Calculate_number_days_in_month.htm