eknath - Saturday, August 22, 2015 12:52 AM:
Hello all,
I am not able to run this code onBeforeUpdate event..
I want to add total cost of items in FM_FORMULABOM and show that Total in textBox of fm_cost..
Innovator inn = this.getInnovator();
string sFormulaId = this.getProperty("id");
//return inn.newError(sFormulaId.ToString());
Item fmbom = inn.newItem("FM_FORMULABOM","get");
fmbom.setAttribute("select","related_id");
fmbom.setAttribute("where","source_id = ' " + sFormulaId+ " ' ");
Item result =fmbom.apply();
return inn.newError(result.ToString());
int count = result.getItemCount();
return inn.newError(count.ToString());
decimal total = 0 ;
for( int i = 0 ; i<count ; i++)
{
Item bom = result.getItemByIndex(i);
Item bompart = bom.getRelatedItem();
string sCost= bompart.getProperty("cost");
if( sCost != null )
{
total = total + Convert.ToDecimal(sCost);
}
}
this.setProperty("fm_cost", Total.ToString());
return inn.newError(total.ToString());
return this;
Please help me..
Shankar - Tuesday, August 25, 2015 12:58 AM:
Hello eknath can try this code i hope u will get actual result
Innovator inn = this.getInnovator();
string vFormulaId=this.getProperty("id");
Item query=inn.newItem("");
string aml = "<Item type='FM_FORMULABOM' action='get' select='related_id, cost'>" +
" <source_id>" + vFormulaId + "</source_id>" +
" <related_id condition='is not null'></related_id>" +
"</Item>";
query.loadAML(aml);
Item Result=query.apply();
int count = Result.getItemCount();
decimal total=0;
for (int i=0; i<count; i++)
{
Item vItemCount = Result.getItemByIndex(i);
string vCost = vItemCount.getRelatedItem().getProperty("cost");
if(vCost!="" && vCost!=null)
{
total=total + Convert.ToDecimal(vCost);
}
}
//return inn.newError(v.ToString());
this.setProperty("fm_cost",total.ToString());
return this;