how to change a field value(variable) if the ritm is approved

AanchalS
Tera Contributor

I have a requirement that when a requested item is approved, I have to change the value of a variable as approved and at the same time store that date in another variable , how can we do that using flow, or is there any more feasible way to do that

 

1 REPLY 1

JenniferRah
Mega Sage

I have a custom action that sets a catalog variable. I pass it the RITM record, variable name and variable value, and it sets the variable to the given value. Here's what it looks like: 

 

Inputs:

JenniferRah_0-1748030441867.png

Script step:

JenniferRah_1-1748030511380.png

JenniferRah_2-1748030531462.png

Script from script step:

(function execute(inputs, outputs) {
try { 
    var variables = inputs.requested_item.variables.getElements(); 
    for (var i = 0; i < variables.length; i++) { 
      var question = variables[i].getQuestion(); 
      
      if (question.getName() == inputs.variable_name) {
        question.setValue(inputs.variable_value);
      }  
    }
    inputs.requested_item.update();
    outputs.state = 'success';
  }
  catch (e) {
    gs.error(e);
    outputs.state = 'error';
  }
})(inputs, outputs);

 

Action Output:

JenniferRah_3-1748030592557.png