on 2018 Jan 16 12:32 PM
Hi experts, i found a problem trying to add a product using ABSL Code.
Basically, i was created a Script that calls a WS (this WS returs a List of products with the ID Product, Quantity and Measure) and when a try to add a product i have a message Exception.
1) Using this way, inside the script in the CustomerQuote Extension BO , the products was added but i have a message exception (The product doesnt exist )
var itemToCreate = this.Item.Create(); //In this line, the exception is raised 😞 itemToCreate.ItemProduct.ProductKey.ProductID.content = material.InternalID.content; itemToCreate.ItemProduct.QuantityMeasureUnitCode = itemResp.GUabsmg; itemToCreate.FirstRequestedItemScheduleLine.Quantity.content = itemResp.zRtCmp ;
2) I tried another way to add a product but i cannot see the node/association ItemProduct.
var itemToCreate : elementsof CustomerQuote.Item;
//In the following lines i have an error because i cannot to access to the association ItemProduct.
itemToCreate.ItemProduct.ProductKey.ProductID.content = material.InternalID.content; itemToCreate.ItemProduct.QuantityMeasureUnitCode = itemResp.GUabsmg; itemToCreate.FirstRequestedItemScheduleLine.Quantity.content = itemResp.zRtCmp ;
There is another way to add the products??
Thanks!!!
Request clarification before answering.
HI Pablo,
In one my similar requirements ,I first created the item with all the mandatory fields and then created product:
Please see the below code. Please let me know if you can create an item with the below approach.
varcreateitem = this.Item.Create();
createitem.Description.content = "Consulting Service";
createitem.ExpectedNetAmount.content = weightedvalue;
createitem.ExpectedNetAmount.currencyCode = "USD";
createitem.Quantity.content = 1;
createitem.Quantity.unitCode = "EA";
if (createitem.ItemProduct.IsSet()){
createitem.ItemProduct.ProductKey.ProductID.content = "10000000";
createitem.ItemProduct.ProductCategoryHierarchyProductCategoryIDKey.ProductCategoryInternalID = "1";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pranav, thanks for the helping.
I tried several times with this way. My problem is with the line,
var createitem = this.Item.Create(); // In debug mode this line raise the message error "The item doesn´t have a product"
Even when the message is raised, the product is created and saved. But the message error still appearing :(.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.