Shantha - Tuesday, January 22, 2013 10:39 PM:
Hi All,
I tried to fetch the contents of item type named ST_A and tried to place into another item type named ST_B which has the same property fields.only thing is ST_A has "bar_no" property field whereas the datas in bar_no need to replaced into "rfid_no" of ST_B other fields are same such as brand,model,etc in both itemtype.
Using below code im able to get 1000 records in 1 shot inside st_base i used for loop to fetch each record from ST_A into ST_B there lies my doubt i dont know to take each record bar_no make to sit inside rfid_no and its brand of ST_A into ST_B "brand". Please help me to sort out.where to change.
debugger;
var inno = new Innovator();
var st_base = inno.newItem("ST_A","get");
st_base = st_base.apply();
if (st_base.isError)
{
return inno.newError("No Items");
}
var count = st_base.getItemCount();
if (count<1)
{
return innovator.newError("No users found.");
}
for (var i=0; i<=3; ++i)
{
var user = st_base.getItemByIndex(i);
var st_electrical = inno.newItem("ST_B","add");
st_electrical.setProperty("rfid_no",$user(i).bar_no);
st_electrical.setProperty("Category",$user(i).category);
st_electrical.setProperty("brand",$user(i).brand);
st_electrical.setProperty("serial_no",$user(i).serial_no);
st_electrical.setProperty("Calibrated",$user(i).Calibrated);
st_electrical.setProperty("Calibrated_date",$user(i).Calibrated_date);
st_electrical.setProperty("Expiry_date",$user(i).Expiry_date);
st_electrical = st_electrical.apply;
}
Can some one guide how to fetch each record 1 by 1 and populate into ST_B from ST_A.
Thanks in advance.Thanks.
asha_gholve - Wednesday, January 23, 2013 2:25 AM:
Hi Shantha,
Use the for loop like
for (var i=0; i<st_base.getItemCount(); i++)
{
;
var st_electrical = inno.newItem("ST_B","add");
st_electrical.setProperty("rfid_no",st_base.getItemByIndex(i).getProperty("bar_no"));
st_electrical.setProperty("Category",st_base.getItemByIndex(i).getProperty("category"));
st_electrical.setProperty("brand",st_base.getItemByIndex(i).getProperty("brand"));
st_electrical.setProperty("serial_no",st_base.getItemByIndex(i).getProperty("serial_no"));
st_electrical.setProperty("Calibrated",st_base.getItemByIndex(i).getProperty("Calibrated"));
st_electrical.setProperty("Calibrated_date",st_base.getItemByIndex(i).getProperty("Calibrated_date"));
st_electrical.setProperty("Expiry_date",st_base.getItemByIndex(i).getProperty("Expiry_date"));
st_electrical = st_electrical.apply;
}
Best Regards,
Asha