I want to keep the old value of rule input in the local variable even if the data has been changed in the rule input later on

Step1: Getting data using rule input. Ex: rule input is of integer type and the current value is 1000.

Step 2: create local variable and fill with the rule input value that is 1000

Step 3: on button click, rule input value gets changed to 2000.

CASE: As soon as rule input value is getting changed my local variable value is also updated with the new value but I don't want to update my local variable value. Local variable value should be 1000 doesn't matter my rule input value gets changed or not.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

      

    Use the a!localVariable(),  inside load() , example as below, once you declare the variable under load it wont change.

    Please use below code as example for reference.

    load(
    
    local!varA:ri!InputValue,
    
    
    a!localVariables(
    
    
    {
    
    a!textField(
    label:"Test"& local!varA,
    value:ri!InputValue,
    saveInto: ri!InputValue
    
    ),
    
    
    
    }
    
    
    
    )
    )

    Click on test interface and provide the input value and , and try updating the value in text field, the value of the local!varA wont change

Reply
  • 0
    Certified Senior Developer

      

    Use the a!localVariable(),  inside load() , example as below, once you declare the variable under load it wont change.

    Please use below code as example for reference.

    load(
    
    local!varA:ri!InputValue,
    
    
    a!localVariables(
    
    
    {
    
    a!textField(
    label:"Test"& local!varA,
    value:ri!InputValue,
    saveInto: ri!InputValue
    
    ),
    
    
    
    }
    
    
    
    )
    )

    Click on test interface and provide the input value and , and try updating the value in text field, the value of the local!varA wont change

Children
  • 0
    Certified Lead Developer
    in reply to karthikkanjerla
    a!localVariable(),  inside load()

    No!  Nobody should be using load() under ANY CIRCUMSTANCES now, it is DEPRECATED.  (Additionally it is BAD PRACTICE to still use load() or with(), because among other things, variables defined using these old functions will not appear in the side-bar variable value monitoring pane, which is critical to proper development and testing.)

    Also, don't put an "a!localVariables()" call inside a load() call, that is nonsensical and won't do anything.

    Instead you ONLY need to use a!localVariables(), with the a!refreshVariable() used in the variable's definition, with the "refresh on referenced var change" parameter passed in as FALSE (it defaults to TRUE for all a!localVariables() variables unless specified as FALSE in this manner). The example code posted down-thread already by is a correct demonstration of this.