This discussion is archived
10 Replies Latest reply: Nov 7, 2012 1:14 PM by 944614 RSS

Temporal Reason Rule Function

944614 Explorer
Currently Being Moderated
I would like to use TemporalYearsSince(<start date>,<end date>) for determining how many years since something has been registered.

The end date would be current date and the start date would be a registration_date.

I created an attribute for the registration_date hoping it would be a base level attribute.

How do I get the interview to ask for the registraion_date instead of asking for the value of TemporalYearsSince(<start date>,<end date>)?

Thanks
  • 1. Re: Temporal Reason Rule Function
    Jasmine Lee Expert
    Currently Being Moderated
    Hi 941611,

    It sounds like TemporalYearsSince may not be the best function to use here. Have you looked at YearDifference?

    the number of years since the thing has been registered = YearDifference(the registration date, the assessment date)

    the assessment date = the current date

    Technically you could put ‘the current date’ directly into the YearDifference rule, but there are best practice reasons to not to. See discussion here for an explanation: changing the current date for testing purposes.

    Cheers,
    Jasmine
  • 2. Re: Temporal Reason Rule Function
    Jasmine Lee Expert
    Currently Being Moderated
    The variables to declare for this example are:

    the number of years since the thing has been registered (number attribute)
    the registration date (date attribute)
    the assessment date (date attribute)

    You don't need to declare 'the current date' as that's the natural language form of a specific function.

    When you test the rule, you should only be asked one base level question: 'What is the registration date?'. The rest of the attributes are inferred.

    Cheers,
    Jasmine
  • 3. Re: Temporal Reason Rule Function
    944614 Explorer
    Currently Being Moderated
    Hi,

    The problem is the question what is the registration date doesn't appear. I believe I don't have the rule tied to an entity or the global entity because it is a level 2 rule that is a condition for the global goal.

    Thanks
  • 4. Re: Temporal Reason Rule Function
    Jasmine Lee Expert
    Currently Being Moderated
    If you're getting asked "What is TemporalYearsSince(<start date>,<end date>)?" then it sounds like the whole string "TemporalYearsSince(<start date>,<end date>)" has been declared as a variable, which is incorrect.

    Aside from this, it sounds like TemporalYearsSince may not be the best function to use anyway. If YearDifference is a more appropriate function, then it would be better to get that working than worry about TemporarlYearsSince.

    Perhaps you could provide some more details? What are your entity levels? Which entity level is the registration date meant to be at? Which entity level is the conclusion (about the number of years since registration) meant to be at?

    Cheers,
    Jasmine
  • 5. Re: Temporal Reason Rule Function
    944614 Explorer
    Currently Being Moderated
    I am tryiing to get YearDifference to work and getting it to match one entity the global entity is trying. I am going to try to move the function up before where I really need it. It decides a conclusion that is used for as a condition for a global conclusion.

    Thanks
  • 6. Re: Temporal Reason Rule Function
    944614 Explorer
    Currently Being Moderated
    With below I am getting expected value: expression, variable, constant (OPA-E00111)

    I have tried putting the YearDifference function in the level 1 and still get error. One global entity just trying a function out.
    The global conclusion with one level one condition. What am I missing?


    Variable_number[minimum years registered]
    Variable_date[condition date] = CurrentDate()
    Variable_number[number of years registered = YearDiffference (the employee's vehicle registration date, condition date)]


    The employee is eligible for a parking space if
    number of years registered > 5
  • 7. Re: Temporal Reason Rule Function
    Ben Rogers Journeyer
    Currently Being Moderated
    hi,
    You are trying to assign values to variables at the same time you declare them (like you can do in Java... int i = 1; for example). You can't do this in OPA.
    See the help topic "use variables in rules":
    http://docs.oracle.com/html/E27987_01/Content/Variables%20and%20constant%20values/Use_variables_in_rules.htm

    To fix your problem:
    Declare the variables first (make sure this is OPM - Configuration style... or better yet, declare these in a properties file)
    It is recommended to always use a lower case "the" before variable names to make your rules more readable.

    Variable_number[the minimum years registered]
    Variable_date[the condition date]
    Variable_number[the number of years registered]

    Once the variables have been declared, you can assign them values using rules (see the help article for full details):

    the condition date = the current date

    the number of years registered = YearDiffference (the employee's vehicle registration date, the condition date)

    the employee is eligible for a parking space if
    ...the number of years registered > 5


    Hope this helps. Shout if you have any more questions.
    Cheers,
    Ben
  • 8. Re: Temporal Reason Rule Function
    944614 Explorer
    Currently Being Moderated
    The variables are declared at the top - configuration style.

    True I normally put definitions in the properties file. So I assume all variable (ie attributes are associated with an entity providing scope). I got the function below from function reference and believe it should return a number type.

    Where can the function below be placed that assigns the value for "the number of years registered"?


    the number of years registered = YearDiffference (the employee's vehicle registration date, the condition date)

    If I place the function at level one than result is trying to use variable while declaring it. If I the function at the top as configuration style as you mentioned I get the message
    "Text in configuration style must match one of the supported configuration functions. Check the text is in the correct style of refer to OPM function reference for supported configuration functions OPA=E00246."

    Regards
  • 9. Re: Temporal Reason Rule Function
    Ben Rogers Journeyer
    Currently Being Moderated
    Hi
    To clarify:
    Declare the variable first (either in a properties file, or at the top of a document using the configuration style as mentioned in my previous post)

    Set the variable using rules by using the conclusion style:
    the number of years registered = YearDifference(the employee's vehicle registration date, the condition date)
    Make sure there are no spaces between YearDifference and the bracket. YearDifference() is correct but YearDifference () is not.

    Now "the number of years registered" has been declared and also set to the number value returned by the YearDifference() function.

    You can then use the variable as a condition in other rules such as

    the vehicle has been registered more than 10 years if
    ...the number of years registered > 10 (level one style)

    Perhaps I've mis-understood what you're trying to do?

    Thanks,
    Ben
  • 10. Re: Temporal Reason Rule Function
    944614 Explorer
    Currently Being Moderated
    Yes, you understood. I missed the part about making the function a conclusion. I didn't think to do that because I thought it would need a condition to satisfy it.

    Thank You

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points