Forum Discussion

LRuoc's avatar
LRuoc
Contributor
2 years ago
Solved

Replacing a Project Variable with new value.

Hello and many thanks for your time in reading this.

 

I have the following piece of code that takes a project variable with the value "Your Incident number is AA99999999" and takes a sub string of the last 10 chars "AA99999999". What I need now is to assign the new value back to the project variable "pvINCNumber"

Can anyone help in how to do this?

 

Code is:-

function GetStringValue()
{
let Str = (Project.Variables.pvINCNumber);  // takes value from project variable (value Your Incident number is AA99999999)
Log.Message("The 'String.substr' INC number is:")
Log.Message(Str.substr(-10, 10)); // last 10 digits is AA99999999
}

  • Resolved it

     

    function GetStringValue()
    {
    //let Str = "Your incident number is INC8393727"; //pvINCNumber
    let Str = (Project.Variables.pvINCNumber);
    Log.Message("The 'String.substr' INC number is:")
    Log.Message(Str.substr(-10, 10)); // last 10 digits

    Project.Variables.pvINCNumber = Str.substr(-10, 10);
    Log.Message("Variable is ", Project.Variables.pvINCNumber);

    }

1 Reply

  • LRuoc's avatar
    LRuoc
    Contributor

    Resolved it

     

    function GetStringValue()
    {
    //let Str = "Your incident number is INC8393727"; //pvINCNumber
    let Str = (Project.Variables.pvINCNumber);
    Log.Message("The 'String.substr' INC number is:")
    Log.Message(Str.substr(-10, 10)); // last 10 digits

    Project.Variables.pvINCNumber = Str.substr(-10, 10);
    Log.Message("Variable is ", Project.Variables.pvINCNumber);

    }