Script is not working

akin9
Tera Contributor

Hello exports,

We have "sn_ind_tmt_orm_order_task" table and "u_site_name" field and related list "sn_ind_tmt_orm_order_characteristic_value" table and "characterstic" is "sitename" this have charactestic_value will be updated through the payload .

 

Requirement is .

We want to update characterstic value in  "u_site_name" field . below script is working but issue is its

updating same value for all the task. please support on this.

 

   var characteristicGR = new GlideRecord('sn_ind_tmt_orm_order_characteristic_value');
    characteristicGR.addQuery('sn_ind_tmt_orm_order_task', current.sys_id); // Filter by the current order task
    characteristicGR.addQuery('characteristic.name', 'sitename'); // Filter by the characteristic name
    characteristicGR.query();

    if (characteristicGR.next()) {
        // Retrieve the characteristic_value (or characteristic_option_value) from the record
        var siteNameValue = characteristicGR.characteristic_option_value; // Replace this with the correct field name if different

        // Ensure we have a valid value before updating the u_site_name field
        if (siteNameValue) {
            current.u_site_name = siteNameValue;
        }
    }
 
Pls support thank you
5 REPLIES 5

akin9
Tera Contributor

Hi @Tushar  

I have tried the same above script but its updated like below.

Its pulling the all location from the characterstics table .FYI

But we want to achive based on each task record we need to update

could you pls help on this?

 

 

 

akin9_0-1732028502598.png