0 Replies Latest reply: Jan 25, 2018 3:30 AM by Marko Zadravec RSS

    Manipulate Load script Variable in Extension

    Marko Zadravec

      Hi,

       

      I would like to manipulate load script inside my extension.

       

      For example, I would like to have a variable with customer Id, that would be calculated inside my extension.

       

      For testing (just to see how this behave) I try this:

       

      In LOAD script:

       

      Set MyVar = 4;

      Exit Script when MyVar<>4;

       

      Inside my extension:

       

      app.variable.setNumValue("MyVar", 5);

      app.doReload(2,false,false).then(function(e) {

                 app.doSave();

      });

       

      This gave me an Internal engine error.


      And even if it would work, I can see the problem, that after doReload is called the MyVar is set to 4 again.

      So my second approach was


      If Len(Trim('$(vScriptVariable1)')) = 0 then

      Set MyVar = 4;

      Else

      Set MyVar = 3;

      End If

      Exit Script when MyVar<>4;

       

      and inside my extension:

       

      app.variable.create({qName : 'vScriptVariable1'});

      app.variable.setStringValue("vScriptVariable1","marko");

      app.doReload(2,false,false).then(function(e) {

                  app.doSave();

      });

       

      But it give me the same error.

      If I change

      app.variable.setStringValue("vScriptVariable1","marko");

      to

      app.variable.setStringValue(vScriptVariable1,"marko");


      error goes away, but nothing happened.


      How to do this right?


      Marko Zadravec