I need to update the description field of the current sc_req_item if record is created through swp.

praveen_rajan
Tera Contributor

Hello everyone,

I need help with a requirement to update the description field of a requested item with any value when an order is submitted through the Service Workspace Portal(SWP). Could anyone assist me in achieving this?

 

Thanks and regards,
Praveen Rajan

2 REPLIES 2

Shubham_Jain
Mega Sage

@praveen_rajan 

 

Create a Business Rule:

  • Navigate to System Definition > Business Rules and click on New.
  • Fill in the basic details for the Business Rule:
    • Name: Update Description on SWP Order Submission
    • Table: sc_req_item (Requested Item)
    • When: Before (so the description is updated before the item is saved)
    • Conditions:
      • Add a condition to check if the item is submitted through the Service Workspace Portal (SWP) by checking the portal context.
      • You can look for the sysportal variable that references the current portal.

Example condition:

 

 

current.portal == 'swp' // Replace 'swp' with your actual portal sys_id if needed

 

 

Write the Script:

  • Under the Advanced tab, write the script to update the description field. Here's a sample script:

 

// Check if the current record is being submitted from the Service Workspace Portal
if (gs.getSession().getClientData('glide.portal') == 'swp') {
    // Update the description field
    current.description = 'Custom value to be added to description'; // Update with the desired value
}

 

 

The key part here is checking if the item is submitted via Service Workspace Portal by using gs.getSession().getClientData('glide.portal'). The value 'swp' is specific to the SWP, but you can replace this with the correct portal sys_id if necessary.

 

Optional - Add Dynamic Descriptions:

  • If you want to populate the description field dynamically (e.g., based on the catalog item or form input), modify the script like this:

 

if (gs.getSession().getClientData('glide.portal') == 'swp') {
    var dynamicValue = 'Order for ' + current.cat_item.getDisplayValue(); // Example dynamic description
    current.description = dynamicValue;
}

 

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


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



Shubham Jain


Thank you for your time, @Shubham_Jain . Unfortunately, it didn't work for me. Below, I've included the snippet of the Business Rule and the `ritm` description. Could you please take a look and let me know if there's anything I need to correct

 

praveen_rajan_0-1729166613403.pngpraveen_rajan_1-1729166639922.pngpraveen_rajan_2-1729166658040.png

 

Thanks and regards,
Praveen Rajan