on 10-24-2016 4:18 PM - last edited on 02-03-2024 5:44 PM by postmig_api_4
I'm currently working on a customization for a client that enters extremely large Customer Returns (several hundred items). Many of the items on the Return can't be linked to existing Sales Orders in ByDesign (i.e. the originating Sales Order).
In the event that they can't determine the Sales Order, they populate it with "NA" or "UNKNOWN" using the "Assign Reference" button on the return screen. However, they have to do this one-by-one. This method works, though, provided it's done in the front-end.
I'm trying to write code to automate this, but both methods that i would expect to work return errors, even though i'm populating data elements identically to what appears in the back-end query when looking at one that was done manually.
Does anyone know the correct method for this?
Here's the code i have so far - running on the CustomerReturn object, BeforeSave event:
import ABSL;
import AP.CRM.Global;
import AP.Common.GDT;
import AP.Common.Global;
//For Each Item Without A Reference
foreach (var FoundItemWithoutReference in this.Item) {
//If The Base Business Transaction Document Reference Does Not Yet Exist
if (!FoundItemWithoutReference.BaseItemBusinessTransactionDocumentItemReference.IsSet()) {
//AddReferenceWithDataProvision Does Not Work
//The Below Code Will Return The Error - "Copying document not possible; reference document does not exist"
var BusinessTransactionDocumentItemKey : BusinessTransactionDocumentItemKey;
BusinessTransactionDocumentItemKey.BusinessTransactionDocumentItemID = "UNKNOWN";
BusinessTransactionDocumentItemKey.BusinessTransactionDocumentKey.BusinessTransactionDocumentID.content = "UNKNOWN";
BusinessTransactionDocumentItemKey.BusinessTransactionDocumentKey.BusinessTransactionDocumentTypeCode = "28";
FoundItemWithoutReference.AddReferenceWithDataProvision(BusinessTransactionDocumentItemKey);
//The Below Code Will Return The Error - "Create not possible; source object inconsistent"
//Create The Blank Business Transaction Document Reference
var BTDR_TypeCode : BusinessTransactionDocumentTypeCode;
var BTDR_ID : BusinessTransactionDocumentID;
var BTDR_ItemTypeCode : BusinessTransactionDocumentItemTypeCode;
var BTDR_ItemID : BusinessTransactionDocumentItemID;
BTDR_TypeCode = "114";
BTDR_ID.content = "UNKNOWN";
BTDR_ItemTypeCode = "28";
BTDR_ItemID = "UNKNOWN";
//Store The Elementsof The To-Be-Created Sales Order Item Reference
var elemItemBusinessTransactionDocumentReference : elementsof CustomerReturn.Item.ItemBusinessTransactionDocumentReference;
elemItemBusinessTransactionDocumentReference.BusinessTransactionDocumentRelationshipRoleCode = "1"; //Role Code 1 - Predecessor
elemItemBusinessTransactionDocumentReference.BusinessTransactionDocumentReference.TypeCode = BTDR_TypeCode;
elemItemBusinessTransactionDocumentReference.BusinessTransactionDocumentReference.ID = BTDR_ID;
elemItemBusinessTransactionDocumentReference.BusinessTransactionDocumentReference.ItemTypeCode = BTDR_ItemTypeCode;
elemItemBusinessTransactionDocumentReference.BusinessTransactionDocumentReference.ItemID = BTDR_ItemID;
elemItemBusinessTransactionDocumentReference.DataProviderIndicator = false; //Data Provider - False, This Is Not A ByDesign Transaction
FoundItemWithoutReference.ItemBusinessTransactionDocumentReference.Create(elemItemBusinessTransactionDocumentReference);
} //End If The Base Business Transaction Document Reference Does Not Yet Exist
} //End For Each Item Without A Reference
Hello Pierre,
Sorry, but I have left this area. 😞
But AFAI remember there was nothing done in this direction.
Bye,
. Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Dan,
If there is no reference why do you need to create one at all?
Do you get an error too if there is no "ItemBusinessTransactionDocumentReference" created?
Bye,
Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pierre,
Sorry, but I am no longer within the PDI topic.
AFAIK there was no update here.
Bye,
. Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Dan,
So you can now tell the support that even the SCN does not know an answer. 😞
Sorry,
Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Dan,
Based on your coding a BTD refrence with the ID "UNKNOWN" must exist if you submit those data. 😞
What about leaving the ID fields empty?
Bye,
Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.