Populate Short Description with Form Variable Values in requested item record

Sahar_Kaizer
Tera Contributor

Hi,

 

I've set up a catalog item named 'change site' that includes fields like 'version,' 'unit,' and 'system.'

Additionally, I've created a business rule that, upon saving the record, should populate the 'short_description' field of the requested item with a string composed of the chosen values in the mentioned fields - 'chosen version / chosen unit / chosen system/ request name', but it doesnt work.

this is the business rule:

Sahar_Kaizer_0-1703688843878.png

 

However, I'm encountering some challenges with this setup. Could someone please provide guidance or suggestions?

 

Thanks,

Sahar

15 REPLIES 15

Also check what are the conditions on your BR , is the catalog item specified on your BR when to run conditions ? I think current.variables.version should also work.

yes it is specified in the when to run condition

Hi @Sahar_Kaizer ,

 

Please try what @SunilKumar_P has suggested that should work. Please let me know if that does not will provide u another script.

 

Thanks,

Danish

 

Anubhav24
Mega Sage
Mega Sage

Hi @Sahar_Kaizer ,

If you are trying to populate values form request form submitted by end user , then you can not use current.<variables> , once the record is saved the variable values are stored in the table "sc_item_option_mtom" you have to query this table to fetch the values.

 

Please mark helpful/correct if my response helped you.

can you please help me modify the script?

(function executeRule(current, previous /*null when async*/) {

    var nonEmptyValues = [];
    if (current.version) {
        nonEmptyValues.push(current.version);
    }
    if (current.unit) {
        nonEmptyValues.push(current.unit);
    }
    if (current.system) {
        nonEmptyValues.push(current.system);
    }

    current.short_description = nonEmptyValues.join('/');

})(current, previous);