Forum Discussion

hkhan's avatar
hkhan
Creator II
4 years ago

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

8 Replies

  • 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.

    • hkhan's avatar
      hkhan
      Creator II

      So im trying the following added code on the property itself, oneditfinish event and i will get the following error[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:51e5b6c0-f8dd-4c91-a76d-0800bbabd927:type=text&text=%20var%20SDRLMDID%20%3D%20document.thisItem.getProperty%28%22vsy_did_master%22%2C%22%22%29%3B%20%0D%0A%20var%20SDID%20%3D%20this.getInnovator%28%29.getItemById%28%22Supplier%20DID%22%2C%20SDRLMDID%29%3B%0D%0A%20if%20%28SDID.getItemCount%28%29%3D%3D1%29%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20this.setProperty%28%22vsy_first_delivery%22%2C%20SDID.getAttribute%28%22id%22%29%29%3B%0D%0A%20%20%20%20%20%20this.setPropertyAttribute%28%22vsy_first_delivery%22%2C%20%22keyed_name%22%2C%20SDID.getProperty%28%22keyed_name%22%2C%20%22%22%29%29%3B%0D%0A%20%20%20%20%7D]

      • angela's avatar
        angela
        Catalyst II

        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!