How to update fields in table from catalog items field after submission of request.

Atchutaram
Tera Contributor

Hi @everone

I have a requirement where i need to update a two fields which are short description and app ID in one table from catalog item fields which are short description and Application ID after submission of the form.

 

How can i do this?

 

Best Regards.

8 REPLIES 8

New Developer_S
Giga Sage

Hi @Atchutaram ,

Assuming your Catalog Item is submitting a RITM, I suggest below solution . 
Use Flow Designer ( low code / no code ) to Trigger the Requested Item ( created or updated ) and then Set Action ( look up record ) And update the record with 
ex: 

Short Description = Requested Item.variables.var_short_description

App ID = Requested Item.variables.var_app_id.


If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

sunil maddheshi
Tera Guru

@Atchutaram 

To update two fields in another table (let's call it the target table) with values from your catalog item fields after form submission in ServiceNow, the recommended way is to use a Catalog Client Script or a Flow (Flow Designer) depending on the use case.

 

Create a flow designer :

 

  • Create a New Flow:

    • Click on New.

    • Name your flow (e.g., "Update Target Table from Catalog Item").

  • Trigger the Flow:

    • Set the Trigger to:

      • Service CatalogCatalog Item Requested

      • Select your specific Catalog Item.

  • Add Action - Update Record:

    • Choose Update Record.

    • Target Table: your custom or destination table (e.g., u_custom_table).

    • Record: The record returned from your lookup or directly specified.

    • Fields to update:

      • Short Descriptionuse Requested Item → Short Description

      • App IDuse Requested Item → Application ID Submit the catalog item and ensure the target table is updated as expected.

      • Please mark correct/helpful if this helps you!

 

Hi @sunil maddheshi , that catalog item already has workflow, adding a new flow will help?

 

Best Regards.

@Atchutaram Maybe you can write BR:

Create the Business Rule

  • Table: sc_req_item

  • When: After Insert

  • Condition item= "Your Catalog Item Name"

  • then write the script something like this
// Ensure application ID is provided
    var appID = current.variables.application_id;
    if (appID) {
      // Try to find a matching record in the target table
    var target = new GlideRecord('u_applications');  // <-- change this to your target table
    target.addQuery('u_app_id', appID);
    target.query();

    if (target.next()) {
        // Update fields from catalog item
        target.u_short_description = current.short_description;
        target.u_app_id = appID;  // If you want to update it again
        target.update();
}
    }

   ​

Please mark correct/helpful if this helps you!