Forum Discussion
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 "ZFCcontrainteTemplate" i 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
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