How to Run already existing Action from a relationship

オフライン

I have this action which runs fine on an itemtype1, I want to use the same action to be triggered when i am on another itemtype2 but itemtype1 is in a relationship. 

Currently im getting an error when i click that action from the relationship,

Parents
  • Probably an issue with the id of your target Item. When you want to use an Action in a grid AND relationship grid, you have to differentiate this in your Method. There are a couple of ways to do this. This is one of them:

    var myId = null;
    var myItem = null;
    // Determine if Action was called from main grid or relationship grid
    var relatedId = this.getProperty("related_id","");

    // relatedId only exists when Action is called from relationship grid
    if (relatedId)
    {
    myId = relatedId;
    myItem = this.getPropertyItem("related_id");
    }
    else
    {
    myId = this.getID();
    lytem = this;
    }

  • 0 オフライン in reply to AngelaIp

    Hello Angelalp

    Im still getting error i added my code in your code below is that 

    The action basically help triggers a workflow on an action, It works fine when i do it on an item type but it has issues when i do it on a relationship grid

    Innovator inn = this.getInnovator();
    Aras.IOM.Innovator innovator = this.getInnovator();
    // var myId;
    // var myItem;
    // Determine if Action was called from main grid or relationship grid
    var relatedId = this.getProperty("related_id","");

    // relatedId only exists when Action is called from relationship grid
    if (relatedId)
    {
    var myId = relatedId;
    var myItem = this.getPropertyItem("related_id");
    }
    else
    {
    var myId = this.getID();
    var lytem = this;
    }


    string workflowMapName = "VSY Task";
    Item workflowMap = innovator.getItemByKeyedName("Workflow Map", workflowMapName);
    if ((workflowMap == null) | (workflowMap.getID().Length != 32))
    {
    return innovator.newError("Unable to retrieve Workflow Map '" + workflowMapName + "'");
    }
    // Instantiate and start the workflow.
    Item workflow = this.instantiateWorkflow(workflowMap.getID());
    if (workflow.isError())
    {
    return innovator.newError("Error instantiating workflow: " + workflow.getErrorDetail());
    }
    workflow.startWorkflow();
    return this;

Reply
  • 0 オフライン in reply to AngelaIp

    Hello Angelalp

    Im still getting error i added my code in your code below is that 

    The action basically help triggers a workflow on an action, It works fine when i do it on an item type but it has issues when i do it on a relationship grid

    Innovator inn = this.getInnovator();
    Aras.IOM.Innovator innovator = this.getInnovator();
    // var myId;
    // var myItem;
    // Determine if Action was called from main grid or relationship grid
    var relatedId = this.getProperty("related_id","");

    // relatedId only exists when Action is called from relationship grid
    if (relatedId)
    {
    var myId = relatedId;
    var myItem = this.getPropertyItem("related_id");
    }
    else
    {
    var myId = this.getID();
    var lytem = this;
    }


    string workflowMapName = "VSY Task";
    Item workflowMap = innovator.getItemByKeyedName("Workflow Map", workflowMapName);
    if ((workflowMap == null) | (workflowMap.getID().Length != 32))
    {
    return innovator.newError("Unable to retrieve Workflow Map '" + workflowMapName + "'");
    }
    // Instantiate and start the workflow.
    Item workflow = this.instantiateWorkflow(workflowMap.getID());
    if (workflow.isError())
    {
    return innovator.newError("Error instantiating workflow: " + workflow.getErrorDetail());
    }
    workflow.startWorkflow();
    return this;

Children