The CreatorCon Call for Content is officially open! Get started here.

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);
 
 
8 REPLIES 8

AshishKM
Kilo Patron
Kilo Patron

Hi @akin9 , 

Can you share the detail for BR, this BR on which table.

Share some screen shots of all three table record link.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

akin9
Tera Contributor

Hi @AshishKM 

Thank you for quick reply!

BR :After : Insert/update .

Table: Interaction.

 

please let me know if any questions.Thanks!

akin9_0-1720538683057.pngakin9_1-1720538715372.png

 

akin9_2-1720538760742.png

 

Thanks for sharing, try with the code shared by @Sandeep Rajput

 

I think we can reduce one Glidequery over inventory if characteristice table has inventory column reference type. We can avoide while over inventory resultset. 

 

characteristic.addQuery('inventory.account', current.acount) ; // manage for ref or string type

 

you can also try to comment the current.update() statement.

 

Share the update, if it works for you or not. 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

@akin9 , just checking about status of this query, does it help or you still have problem with code.

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution