how to set property for propery with data type "object"?

オフライン

hello 

i have added a property on the Project item type. this property is "object" data type 

and i simply wanted to know if it is possible to programatically set this property.

any information about this topic would really help me 

for now i have tried to set it with this little test method that i run on a project action :

var inn = this.getInnovator();

var thisID=this.getID();

var itemProjet = inn.getItemById("Project",thisID );
console.log(itemProjet.getProperty("name"));
var template = inn.getItemByKeyedName("ZFCcontrainteTemplate","rohs int not bool"); //
itemProjet.setProperty("zfctemplate","rohs int not bool"); // i've tried with name and ID
console.log(itemProjet.getProperty("zfctemplate"));

after running this method i get really strange result , first the field associated to my property isn't updated even when i quit and reload the project and i get some locking errors if i try to modify it again

thanks,

Lucas

Parents
  • Hi Lucas

    When is this method triggered ? Object data type are you referring to Item ?

  • 0 オフライン in reply to Gopikrishnan

    hi

    my method is trigered by an action. For object data type i mean when you create a property on an item type and define it's type (like string int list ) the object type  is particular because you need to set a data source also.

    in my case i added a property to the "project" item type and the type is object with data source "ZFCcontrainteTemplate" which is an item type i created.

     the method is asking the user to select an item "ZFCcontrainteTemplatei then need to store the item used and i want it to appear on the form of the project, for this i created a new field on the form and linked it to my property (the fields that makes a search dialog pop up). In the end my goal is to enable the user to select an item from the form and use it when my method runs or if it's not selected before method runs the search dialogs pop from the method and stores the selected item.

    thanks,

    lucas

  • 0 オフライン in reply to lucas

    var inn = this.getInnovator();

    var thisID=this.getID();
    console.log(thisID);
    var itemProjet = inn.getItemById("Project",thisID );
    console.log(itemProjet.getProperty("name"));

    var resGetObjProp= itemProjet.getProperty("zfctemplate");// on recupere un id

    console.log("resGetObjProp: "+resGetObjProp);
    if(resGetObjProp!== undefined){
    var itemZFCtemplate = inn.getItemById("ZFCcontrainteTemplate",resGetObjProp );
    console.log(itemZFCtemplate.getProperty("name"));}

    var template = inn.getItemByKeyedName("ZFCcontrainteTemplate","template not cliked field");
    var templID=template.getID();
    console.log("newtemplID: "+templID);
    itemProjet.setProperty("zfctemplate",template.getID());

    var resGetObjProp= itemProjet.getProperty("zfctemplate");// on recupere un id

    console.log("resGetObjProp: "+resGetObjProp);
    var itemZFCtemplate = inn.getItemById("ZFCcontrainteTemplate",resGetObjProp );
    console.log(itemZFCtemplate.getProperty("name"));

    i'm runnig this on a project where my prop "zfctemplate" is undefined 

    i' get that in the console:

    A1B25E8006A44F089760C05A7F04B9E7
    FCV3 testing
    resGetObjProp: undefined
    newtemplID: 3DC8D4E0ABFE4156897360A22E27F8DD
    resGetObjProp: 3DC8D4E0ABFE4156897360A22E27F8DD
    template not cliked field

    it seems that the property has been set but it's not visible on the form.

    Other thing  is if i re run that method we shouldn't get the first resGetObjProp being undefined but it actually does.

    to me it looks like after my method is ran nothing is saved but i have no idea why.

    lucas

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

    var inn = this.getInnovator();

    var thisID=this.getID();
    console.log(thisID);
    var itemProjet = inn.getItemById("Project",thisID );
    console.log(itemProjet.getProperty("name"));

    var resGetObjProp= itemProjet.getProperty("zfctemplate");// on recupere un id

    console.log("resGetObjProp: "+resGetObjProp);
    if(resGetObjProp!== undefined){
    var itemZFCtemplate = inn.getItemById("ZFCcontrainteTemplate",resGetObjProp );
    console.log(itemZFCtemplate.getProperty("name"));}

    var template = inn.getItemByKeyedName("ZFCcontrainteTemplate","template not cliked field");
    var templID=template.getID();
    console.log("newtemplID: "+templID);
    itemProjet.setProperty("zfctemplate",template.getID());

    var resGetObjProp= itemProjet.getProperty("zfctemplate");// on recupere un id

    console.log("resGetObjProp: "+resGetObjProp);
    var itemZFCtemplate = inn.getItemById("ZFCcontrainteTemplate",resGetObjProp );
    console.log(itemZFCtemplate.getProperty("name"));

    i'm runnig this on a project where my prop "zfctemplate" is undefined 

    i' get that in the console:

    A1B25E8006A44F089760C05A7F04B9E7
    FCV3 testing
    resGetObjProp: undefined
    newtemplID: 3DC8D4E0ABFE4156897360A22E27F8DD
    resGetObjProp: 3DC8D4E0ABFE4156897360A22E27F8DD
    template not cliked field

    it seems that the property has been set but it's not visible on the form.

    Other thing  is if i re run that method we shouldn't get the first resGetObjProp being undefined but it actually does.

    to me it looks like after my method is ran nothing is saved but i have no idea why.

    lucas

Children
No Data