Need help on script to populate short description on RITM.

Nandini Gupta
Tera Contributor

Hi everyone,

 

I need to populate short description on RITM based on choices select through catalog. For example if I select Q1=a then Q2 selected choices on catalog need to populate on RITM short description or if I select Q1=b then Q3 selected choices on catalog need to populate on submitted RITM short description.

Can anyone help me with script for that?

3 REPLIES 3

ali bhatti
Tera Contributor

 

 

Hi @Nandini Gupta,

Yes, you can achieve this using either Flow Designer or a Business Rule to populate the Short Description on the RITM based on the selected catalog variables.

Option 1: Flow Designer

Create a flow and attach it to your Catalog Item. Use the "Catalog Item Requested" trigger. In the flow:

  1. Add a action "Get Catalog Variables" step to access the values of Q1, Q2, and Q3.

  2. Use a "update record" action to update the RITM's Short Description field based on the value of Q1.

Example logic:

  • If Q1 = a, populate from Q2

  • If Q1 = b, populate from Q3


Option 2: Business Rule

You can also use a Business Rule on the sc_req_item table (RITM) like this:

 

 
(function executeRule(current, previous) { var q1 = current.variables.q1; if (q1 == 'a' && current.variables.q2) { current.short_description = 'Q1: a | Q2 selection: ' + current.variables.q2.getDisplayValue(); } else if (q1 == 'b' && current.variables.q3) { current.short_description = 'Q1: b | Q3 selection: ' + current.variables.q3.getDisplayValue(); } })(current, previous);
  • Use a Before Business Rule (on insert/update) so the short description is set before saving.

  • Ensure variable names (q1, q2, q3) match your actual variable names in the catalog item.

 

Regards,

Saadat Ali

Shubham_Jain
Mega Sage

@Nandini Gupta  - Can you try this

 

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading || newValue == '') {
    return;
  }

  var q2 = g_form.getValue('Q2');
  var q3 = g_form.getValue('Q3');
  var shortDesc = '';

  if (newValue == 'a') {
    shortDesc = 'Request for Q2: ' + q2;
  } else if (newValue == 'b') {
    shortDesc = 'Request for Q3: ' + q3;
  }

  g_form.setValue('short_description', shortDesc);
}

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


nemamuskan
Tera Contributor

Hello @Nandini Gupta,

 

Please try setting the values with flow designer. I am attaching the screenshot of flow you can refer and create same as it is it would work.

 

Hope my answer helps your requirement. Also feel free to ask if there is any doubt in the flow created in the screenshot attached.

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Thanks and Regards,

Muskan