Property value

Shir Sharvit
Tera Contributor

 

Hey
I have a business rule code
who accesses a suitable property in any condition.
I want to add a line to the code that will extract the value from the property that returns in line 24

ShirSharvit_0-1718708190144.png

The code:

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

    var property;
    var reduced_priority;


    if (current.priority == 1) {
        property = 'critical_response_sla';
        reduced_priority = 2;
    }
    if (current.priority == 2) {
        property = 'critical_response_sla';
        reduced_priority = 3;
    }
    if (current.priority == 3) {
        property = 'critical_response_sla';
        reduced_priority = 4;
    }
    if (current.priority == 4) {
        property = 'critical_response_sla';
        reduced_priority = 4;
    }

    property = gs.getProperty(property);


    var time = 18;
    var dt = new GlideDateTime();
    dt.addDaysLocalTime(time);
    gs.eventQueueScheduled("incident.priority.reduce", current, current.priority, reduced_priority, dt);


})(current, previous);

I would be happy to help

Thanks Shir




4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@Shir Sharvit Here is the updated code..

 

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

    var property;
    var reduced_priority;


    if (current.priority == 1) {
        property = 'critical_response_sla';
        reduced_priority = 2;
    }
    if (current.priority == 2) {
        property = 'critical_response_sla';
        reduced_priority = 3;
    }
    if (current.priority == 3) {
        property = 'critical_response_sla';
        reduced_priority = 4;
    }
    if (current.priority == 4) {
        property = 'critical_response_sla';
        reduced_priority = 4;
    }

    var propVal = gs.getProperty(property); //This will fetch the assigned property value
   gs.addInfoMessage(propVal); //Shows the property value using an infoMessage. 

    var time = 18;
    var dt = new GlideDateTime();
    dt.addDaysLocalTime(time);
    gs.eventQueueScheduled("incident.priority.reduce", current, current.priority, reduced_priority, dt);


})(current, previous);

 

I have defined a new variable propVal which captures the property value. You can use this variable later on to use it in your script.

 

Hope this helps.

Hey
I want to extract the value of the Property,
Do not display it in infoMessage

@Shir Sharvit 

gs.getProperty('property name');

Is used to extract the value of the property. 

 

In the code 

 var propVal = gs.getProperty(property);

 

The variable propVal holds the value of property. 

 

@Shir Sharvit Please mark the response as accepted solution if it addressed your question.