onBeforePromote: how to take the id value?

オフライン

Hello, I have created a method in c#, in which I take the ID value and do some things.

The fact is that if I put the method in onBeforePromote, it gets a null value, I have tried it in 3 possible ways. The strange thing is that if I put that method in another event, like , it takes the ID value correctly.

Innovator innovator = this.getInnovator();

var id=this.getID();
var OrdenID1 = this.getProperty("id");
var OrdenID2 = document.thisItem.getProperty("id");

//var OrdenID = this.getProperty("id");

//string StateOF = this.getProperty("state","");
//string EstadoOF = this.getProperty("estado_cv","");

return innovator.newError("AA " + id + "BB "+OrdenID1 + "CC "+ OrdenID2);

  • Hi,

    there is not id when using onBeforePromote. Throw an error message just with "this" and you will see. 

    It only contains an idlist:

    Innovator inn = this.getInnovator();

    // Get the Items(s) affected by this promotion
    string idlist = this.getAttribute("idlist");

    // Get items by idlist
    Item xy= inn.newItem("xy", "get");
    xy.setAttribute("idlist", idlist);
    xy.setAttribute("select","xy");
    xy= xy.apply();

    // Prevent execution of code if more than one items was selected (if you want this behavior...)
    int itemCount = xy.getItemCount();
    if (itemCount > 1)
    {
      return inn.newError("This action only works for one item...");
    }

    onBeforePromote is not my favourite kind of event. If you can achieve the same behavior with a LifeCycle pre Method, better use this one!

    Bye

    Angela