1
votes

I hope this is a simple fix but I'm not experienced in xPages...

I have an order app. I enter the customer ID, it looks it up and displays the information. Then in a type ahead I enter the product the customer is ordering. It looks it up, displays applicable information and allows me to put in the Qty ordered. I have a save/update button that is pressed to save this item in its own record with the Order ID as key. I have a view control below that filters by this Order ID (but that's not displaying either). The item ordered is saved. Then I enter another item number to order a second item. It displays, I enter the Qty and click save. In the save button, it's setting all the fields that I need on that document and then saving. The second time around, it's only updating the first one, not creating a second one. I put a createdocument command in and it errors out. Is there some command I can use to clear the system of the first item? In the view control, the user can click an item and it will display in the "current working item" area that displays when I create a new one. Is this confusing? Thanks for your help.

Mike

Here is the code of the button. The form is a data source on the xPage (docItem). I also tried putting a data source on the panel containing the Item info and view. Same results. My fields get the data from viewScope variables as you can see below... document1 is the main Order doc with customer info stored, etc. I don't save this until the user first orders an item....

document1.save();

vItemPrice = viewScope.vsItemCsPricing1;
viewScope.vsItemPrice = vItemPrice;
viewScope.vsItemExtPrice = vItemPrice * 3;

docItem.setValue("ItemPartNbr", viewScope.vsItemPartNbr);
docItem.setValue("ItemOrderUNID", viewScope.vsOrderUNID);
docItem.setValue("ItemPrice", viewScope.vsItemPrice);
docItem.setValue("ItemExtPrice", viewScope.vsItemExtPrice);
docItem.setValue("ItemDesc", viewScope.vsItemDesc);
docItem.setValue("ItemQty", getComponent("ItemQty").getValue())

docItem.save();

viewScope.vsItemFullDesc = "";
viewScope.vsItemDesc = "";
viewScope.vsItemPartNbr = "";
viewScope.vsItemCatNbr = "";
viewScope.vsItemUPCCode = "";
viewScope.vsItemCartUPCCode = "";
viewScope.vsItemCsPricing1 = "";
viewScope.vsItemCsPricing2 = "";
viewScope.vsItemCsPricing3 = "";
viewScope.vsItemQtyAvail = "";
viewScope.vsItemDiscInd = "";
viewScope.vsItemQtySold12 = "";
viewScope.vsItemCsQty = "";
viewScope.vsItemQty = "";
viewScope.vsItemPrice = "";
viewScope.vsItemExtPrice = "";
viewScope.vsItemStatus = "";
1

1 Answers

2
votes

docItem seems to be a document data source. It will stay the same as long as you have XPage open. Every docItem.save() will save values to same document.

Don't define docItem as data source. Create a document right in your save button code with
var docItem = database.createDocument() and apply viewScope variable values to it.

Example:

var docItem = database.createDocument();
docItem.replaceItemValue("Form", "fOrderLineItem");
docItem.replaceItemValue("ItemPartNbr", viewScope.vsItemPartNbr);
...
docItem.save();

You'll get different Item documents then.