Dayalan Punniyamoorthy Blog

Monday, December 18, 2023

Add a New row to enter data for a New Product or a Customer - Using Groovy Part 2

 In the Part -1  we saw how to add a new row for a New Product or a Customer using the Calculation Manager rule. In this post, we will see how to do the same using the Groovy rule. 

This is the data from where add a row option is enabled,


Column A is hidden and the rest of the column will be visible.


The actual form is shown below, 

A Menu "Groovy Add a Row" is added to the Form.
Invoking the Menu triggers a Groovu Rule and you can pick the combination you want to populate for, For example, the specific Product and customer where you would be interested in entering data that was not available before in the form. 
Here the Entity, Market & Currency Dimensions will be auto-populated by the rule. 


The calc script generated and excuted can be validated fron the Job console, 





A New line is added for the users to enter data for the Selected Product & Customer.  

The Groovy script is

/* RTPS: {Account} {Entity} {Currency} {Product} {Customer} {Market} */

/* Initialize a string variable named calcScript*/

/* Generate the calc script to copy a value to the selected Product.*/

String calcScript = ""

/* Assign a multiline string to calcScript using triple quotes*/

calcScript ="""

  /* FIX statement with multiple parameters*/

  FIX({Account},&PlanStartYr,"OEP_Plan","OEP_No Version",{Entity},{Currency},{Customer},{Market},"No Period")

 /* Set the value of {Product} to 0.00001*/

 /*   {Product} = #Missing;*/

{Product} = .00001;

ENDFIX

"""

/* Print a message indicating the user who executed the rule and the generated calculation script.*/

println("Data aggregation was executed by $operation.user.fullName: \n $calcScript")

/*Return the calculation script, which will be executed.*/

return calcScript.toString()


Hope this helps, happy days on the Cloud!!!






1 comment: