Script check to get value

akin9
Tera Contributor

Hello Experts,

We have "product inventory" table having "account field " and under that "Product characteristics" related lists available.

Requirement.

Account having "TSP" field and one "TSP" field on the interaction.

1.After creating a interaction Product.account.Tsp value need to update in the Interaction

Based on below script query mets. but below script is not working as expected 

please correct me.

BR :After : Insert/update .

Table: Interaction.

 

(function executeRule(current, previous) {
    var account = current.account.toString();
    var inventory = new GlideRecord('sn_prd_invt_product_inventory');
    inventory.addQuery('account', account);
    inventory.query();
 
    while (inventory.next()) {
   
        var characteristic = new GlideRecord('sn_prd_pm_product_characteristics');
        characteristic.addQuery('inventory', inventory.sys_id);
        characteristic.addEncodedQuery('characteristic.nameSTARTSWITHadditionalInfo^characteristic_valueLIKE"telecomServicePriority"')
        characteristic.query();
 
        if (characteristic.next()) {
           current.u_tsp = inventory.account.u_tsp_level;
            current.update();
            break;
        }
    }
})(current, previous);