eknath - Thursday, December 24, 2015 2:27 AM:
Hii everyone,
I have written code in javascript on click event, but i am not able to get property of SYMBI_QUANTITY.
Error-" unable to get property 'getproperty of undefined or null reference'"
innovator=document.thisItem.getInnovator();
var vFormulaId=document.thisItem.getProperty("id");
var query=innovator.newItem("");
var aml = "<Item type='SYMBI_ITEM_MATERIAL_RECEIVED' action='get' select='RELATED_ID,SOURCE_ID'>" +
" <SOURCE_ID>" + vFormulaId + "</SOURCE_ID>" +
" <RELATED_ID condition='is not null'></RELATED_ID>" +
"</Item>";
query.loadAML(aml);
var result=query.apply();
var count = result.getItemCount();
alert(count);
for (var i=0; i<count; i++)
{
var vItem=innovator.newItem("SYMBI_BIN CARD","get");
var vItemCount = result.getItemByIndex(i);
var vRelation=vItemCount.getRelatedItem(vItem);
var sQuantity=vRelation.getProperty("SYMBI_QUANTITY ");
alert(sQuantity);
}
any solution please help..
tstickel - Friday, December 25, 2015 9:26 AM:
eknath
You have used getRelatedItem() incorrectly. This method does not take a parameter, so it should be
var vRelation=vItemCount.getRelatedItem();
It is possible that Innovator may just ignore the parameter that you included.
In your statement, var sQuantity=vRelation.getProperty("SYMBI_QUANTITY "); you have a blank at the end of the property name that should not be there.
Also, I assume that SYMBI_QUANTITY is a property of the related itemtype referenced in your first query. If so, then the select clause in that AML should be
select='RELATED_ID(SYMBI_QUANTITY),SOURCE_ID'
eknath - Saturday, December 26, 2015 12:35 AM:
tstickel,
I have done all changes which u mentioned,still i am not getting property of SYMBI_QUANTITY.
SYMBI_QUANTITY is a property of SYMBI_BIN CARD.
SYMBI_ITEM_MATERIAL_RECEIVED is related item type referenced.
code
innovator=document.thisItem.getInnovator();
var vFormulaId=document.thisItem.getProperty("id");
var query=innovator.newItem("");
var aml = "<Item type='SYMBI_ITEM_MATERIAL_RECEIVED' action='get' select='RELATED_ID(SYMBI_QUANTITY,SOURCE_ID'>" +
" <SOURCE_ID>" + vFormulaId + "</SOURCE_ID>" +
" <RELATED_ID condition='is not null'></RELATED_ID>" +
"</Item>";
query.loadAML(aml);
var result=query.apply();
var count = result.getItemCount();
alert(count);
for (var i = 0; i < count; i++)
{
var vItem=innovator.newItem("SYMBI_BIN CARD", "get");
var vItemCount = result.getItemByIndex(i);
var vRelation=vItemCount.getRelatedItem();
var sQuantity=vRelation.getProperty("SYMBI_QUANTITY");
alert(sQuantity);
}
tstickel - Saturday, December 26, 2015 9:54 AM:
Hi
Your select clause is missing a right parenthesis:
you have select='RELATED_ID(SYMBI_QUANTITY,SOURCE_ID'
it should be select='RELATED_ID(SYMBI_QUANTITY),SOURCE_ID'
But this may not fix your problem because I am not clear on what your data model is. You say that SYMBI_ITEM_MATERIAL_RECEIVED is "related item type referenced". Yet your AML is written as if SYMBI_ITEM_MATERIAL_RECEIVED what is usually called a "relationship itemtype". If it is a "relationship itemtype" then it is used to hold the relationships between a "source" itemtype and a "related" itemtype.
So the question is this: In the itemtype definition of SYMBI_ITEM_MATERIAL_RECEIVED, what is defined as the Data Source for the related_id property? If the Data Source for the related_id property is SYMBI_BIN CARD then adding the right parenthesis to the select clause should fix your problem.
If the Data Source for the related_id property is not SYMBI_BIN CARD then I would need to understand how SYMBI_BIN CARD fits in your data model.