populate defaul property via javeascript

When i create a new item via a relationship called Subcontract, there is a property called MASTER_DID on subcontact which is datatype item as well, when the user selects a MASTER_DID the owner of MASTER_DID  should auto populate with the owner of Subcontract. This needs to all happen on the grid. How can i achieve that via client event

Parents
  • Without image the question is a little bit hard to understand

    But maybe you could use a "onAfterNew" Client Event in your ItemType. E.g. check out Method 'PE_SetOriginator". This one is used very often to set the owner property automatically.

  • So im trying the following added code on the property itself, oneditfinish event and i will get the following error

     var SDRLMDID = document.thisItem.getProperty("vsy_did_master",""); 
     var SDID = this.getInnovator().getItemById("Supplier DID", SDRLMDID);
     if (SDID.getItemCount()==1)
        {
            this.setProperty("vsy_first_delivery", SDID.getAttribute("id"));
          this.setPropertyAttribute("vsy_first_delivery", "keyed_name", SDID.getProperty("keyed_name", ""));
        }

  • You cannot use document.thisItem outside the context of a Form. Better try "this". Or take a look at "PE_SetTeam" which is maybe the better sample in your case.

    Otherwise show screenshots of the situation cause I really don´t know what you try to do ;-)

    Edit: My sample Methods where intended as onAfterNew "Client Events" not as property events. So beware!

  • okay so ill rephrase the issue again:

    There are two items Master DID and SDRL

    Both these item contains a property called first_delivery which is a string data type.

    Supplier DID has a property called master_did which is an item property links to Master DID item.

    There is a third item called subcontract, when the user creates a new SDRL from the relationship in subcontract item and select master_did I want first_delivery to be populated instantly from Master DID before saving.

    Please not: it cannot be foreign property as it should be editable

     

    Following are the screen shots.

  • Hi HKhan

    Attach this method to DID Master Property - OnEditFinsh

    let selectedMasterDID = gridApplet.cells(relationshipID, colNumber).getValue();
    if(selectedMasterDID)
    {
    var getMasterDID = aras.getItemById("Master DID", selectedMasterDID);
    setRelationshipProperty(relationshipID, 'first_delivery', aras.getItemProperty(getMasterDID, "first_delivery","")); //If first_delivery property is in relationship then use this line
    setRelatedItemProperty(relationshipID, 'first_delivery', aras.getItemProperty(getMasterDID, "first_delivery","")); // If first_delivery property is in Related Item then use this line
    }

  • hello 

    I am getting the following error when i apply this, any idea why? relateditem seems to be defined already

Reply Children