Adventures in Groovy – Part 4: Run Time Prompts

Print

Introduction

Groovy provides a very easy way to interact with the user via run time prompts, or RTPs.  These can be linked to dimensions, members, and input.  One of the huge benefits of getting RTPs in Groovy is that the result can be validated, and the calculation can be cancelled if they don’t validate (we will touch on this in a future post).

The Solution

This is one of the easier things to do with a Groovy calculation.  There are two things required.  First, the Groovy calculation must prompt the user to select a value.  This is done by doing the following.

At any point in the script after the above, the value can be used.  If it is going to be used multiple times, it might be easier to set a variable.  Regardless of the approach, the value can be referenced using the rtps object as follows.

That is all that is required!

Conclusion

Beyond the obvious uses of an RTP, I have started using these for a number of other reasons.

  • On global forms where multiple values may be changed throughout a short period of time and execute long running calculations, like allocations, I have seen benefits of prompting a user with a yes/no smartlist RTP.  If the user has more changes, they may not need to execute the calculation after every save.  This gives them the option.
  • If there is a requirement where some prompts are dependent on other prompts, using RTPs in Groovy gives you the flexibility to validate the combination.  For example, if an employee is set to hourly with a VP title, the prompts can be validated and returned to the user as invalid combinations before the prompts are removed from user view.

Please follow and like us:
RSS
Facebook
PINTEREST
LinkedIn
 

8 Comments

  1. I have this in my groovy BR.
    String sRTP
    sRTP = rtps.UserSL.toString()

    I have UserSL as Global RTP
    Still I get below error
    No Rtp with the name found.

     
    • Do you have the following at the top of your rule? It looks like a comment but it is actually embedding the RTP in the rule to be used.
      /*RTPS: {UserSL}*/

       
        • I had the same issue the first time I used it – it is a little confusing :). Glad I could help. If you have multiple RTPs, just put a space between them, like
          /*RTPS: {RTP1} {RTP2}*/

           
  2. Hi Kyle,

    Thanks for great blog !
    I am trying to use RTP for smartpush and datamap, somehow I am not getting the Department variables RTP and it’s not recognizing. I am able to get RTP for other dimensions. Do you see any issue with this code

    /*RTPS: {VarDepartment} */
    String sRTP
    sRTP = rtps.VarDepartment.toString()
    operation.application.getDataMap(“CapexToCapexReporting”).execute(“Department”:sRTP, false)

     
    • I believe you need to reference all the RTPs in one line, so I would expect to see something like this in your example: *RTPS: {VarOtherDim1 VarOtherDim2 VarDepartment} */

       
  3. Thanks for the reply. I did tried that, but Department RTP variable is not recognizing. Do you see any other issue

    /*RTPS: {varDepartment} {varEntity} {varSite}*/

    String sRTPSEntity
    String sRTPSDepartment
    String sRTPSSite
    sRTPSEntity = rtps.varEntity.toString()
    sRTPSDepartment = rtps.varDepartment.toString()
    sRTPSSite = rtps.varSite.toString()
    operation.application.getDataMap(“FCSTTest”).createSmartPush().execute([“Department”:sRTPSDepartment,”Entity”:sRTPSEntity,”Site”:sRTPSSite])

    Thanks
    Senthil

     

Leave a Reply

Your email address will not be published. Required fields are marked *