For partners that build or integrate commercially available applications and service solutions with the Oracle Cloud Platform
For partners that provide implementation or managed services around Oracle Cloud Applications
Hello,
I have a VBCS screen composed of a Header section and a Lines Section. The header section is tied to a BO while the lines section is based on an ADP. There will always be one header record to many Lines records.
I've created an integration in ICS to upload the screen data to two files on an FTP Server where the files will be picked up and processed via FBDI.
The payload is collected in a vbcs variable based on a variable type tied to the ICS REST endpoint.
It all works as long as I have one header (no problem) and one line. It does not work if I have many lines as it simply just adds the first line. The REST Service does not seem to take the array or recognize that item[i] is an array in the payload.
I have correctly mapped the Lines Array to the endpoint via the variable created based on the endpoint.
Headers works fine but I cannot get multiple lines generated.
Also, I've tested the endpoint in VBCS on the services page with the JSON and that works fine posting multiple lines for each header. So I am at a loss as to why the array is not recognized. This is a POST action but to ICS to create the two files. The service does not error due to content type but works regardless of how many lines I have by creating only one line. Please advise.
Am I missing anything?
here is the JSON that works when testing directly from VBCS in the Services Page for the app:
{
"hdrItems":
{
"docNumber":"123456",
"fromDocNumber":"123456",
"budgetLevelId":"1",
"treasurySymbol":"000-00-0000",
"fundValue":"0000",
"publicLawCode":"001-001",
"transactionDate":"2019-04-24",
"docTotal":"123456789",
"fahEvent":"APPROP",
"hdrDescription":"abcdefg"
},
"lineItems":[
{
"lineDocNum":"123456",
"glDate":"2019-04-24",
"glAccountString":"000000000",
"segment1":"0000",
"segment2":"000000.00",
"segment3":"000000",
"segment4":"0000",
"segment5":"000000",
"segment6":"2019",
"segment7":"000",
"transactionType":"Appropriation",
"lineAmount":"123456789",
"lineDescription":"abcdefg",
"lineNum":"1",
"id":"123456",
"headerId":"123456"
},
{
"lineDocNum":"123456",
"glDate":"2019-04-24",
"glAccountString":"000000000",
"segment1":"0000",
"segment2":"000000.00",
"segment3":"000000",
"segment4":"0000",
"segment5":"000000",
"segment6":"2019",
"segment7":"000",
"transactionType":"Appropriation",
"lineAmount":"123456789",
"lineDescription":"abcdefg",
"lineNum":"2",
"id":"123456",
"headerId":"123456"
}
]
}
Thanks,
Steve
Comment
How are you assigning the lines to the variable that you are passing to the service?
If you look at the payload sent to the REST endpoint - does it have more than one row in there?
Is your issue passing the value correctly from VB, or getting it correctly in the integration layer?
Be the first to rate this
|
Sign in to rate this
Shay,
I need to re-work the lines Payload. The shape is fine but the fields names do not match so its not picking up anything unless I map the fields directly which will only result in one line. There are multiple lines but one header.
Does that make sense? I think the field names also need to match so I do not have to map them individually to the :Payload variable. This is all in VBCS.
Thanks,
Steve
Be the first to rate this
|
Sign in to rate this
Yes that makes sense.
If you already have everything defined and you don't want to change that, you can also create an additional array with the right field names, and use a page module JS function to assign the values into that array from your existing SDP/ADP.
Be the first to rate this
|
Sign in to rate this
Shay,
That is a great idea! That is what I will do.
Thanks so much for your help as always,
Steve
Be the first to rate this
|
Sign in to rate this
Shay,
I have the following Array I need to map with the function.
getAllVBCSLines (source)
accountSegment
fundSegment ... and so forth
I have the following target Array to which the function needs to map
As you can see, there are two arrays in the Payload (one for headers and one for lines)
trxLinesArrayPayload (target)
hdrItems (array)
docNumber
docTotal
fundValue ... and so forth
lineItems (array)
docNumber
glAccountString
glDate ... and so forth
attaching pictures below.
The headers will come from a business object
The lines are coming from the Array assigned to the ADP
I am not sure how to structure the function to refer to only the lineItems. Here is my code so far:
PageModule.prototype.mapTrxToPayload = function(trxLinesArray, trxNewLinesArray) {
trxLinesArray.accountSegment = trxNewLinesArray.segment2;
trxLinesArray.activitySegment = trxNewLinesArray.segment4;
trxLinesArray.amount = trxNewLinesArray.lineAmount;
trxLinesArray.bfySegment = trxNewLinesArray.segment6;
trxLinesArray.description = trxNewLinesArray.lineDescription;
trxLinesArray.docNumber = trxNewLinesArray.docNumber;
trxLinesArray.fundSegment = trxNewLinesArray.segment1;
trxLinesArray.glAcct = trxNewLinesArray.glAccountString;
trxLinesArray.glDate = trxNewLinesArray.glDate;
trxLinesArray.lineNum = trxNewLinesArray.lineNum;
trxLinesArray.objectSegment = trxNewLinesArray.segment5;
trxLinesArray.programSegment = trxNewLinesArray.segment3;
trxLinesArray.orgSegment = trxNewLinesArray.segment7;
trxLinesArray.transactionType = trxNewLinesArray.transactionType;
return trxNewLinesArray;
Any suggestions on how to map this in the action chain?
Thanks,
Steve
Be the first to rate this
|
Sign in to rate this
Shay,
Do I have to actually create another ADP to initialize the new array and then populate it with the values from the old array for the new columns? I was hoping to populate an array behind the scenes. I keep getting cannot read property 'segment1'(for example) or undefined).
Right now, it is not recognizing my variable when I invoke the function for the new array so I am thinking I need to initialize it in the UI?
Steve
Be the first to rate this
|
Sign in to rate this
You don't need an ADP - you need an array.
You send one array into the JS function - loop over the records - assign them to a new array with the right structure and return this new array. You then use an assign variable to assign the new array returned from the JS to the variable you are passing as a body to the POST method.
Maybe this will help - https://blogs.oracle.com/shay/working-with-arraydataproviders-in-javascript-functions-in-visual-builder
Be the first to rate this
|
Sign in to rate this
Shay,
Right now I am trying to loop over the ADP variable that the table is tied to. Every time I attempt to update the new array, I get a the error.
How does the function know about the new array if I do not pass it as a parameter? Do I assign the values in the action chain?
I am missing something about this. I will check out the link.
Steve
Be the first to rate this
|
Sign in to rate this
The new array you are creating in the JS is returned from the JS and assigned into a page variable after the call.
See another example around 8:45 and onwards here -
https://blogs.oracle.com/shay/charts-in-oracle-visual-builder-data-structure-and-performance-tips
Be the first to rate this
|
Sign in to rate this
Ahh, so you are saying I create the array itself in the javascript and then map the function result to the payload type.in the action chain. Is that correct?
Be the first to rate this
|
Sign in to rate this
Yes
Be the first to rate this
|
Sign in to rate this
Okay, off I go!
Be the first to rate this
|
Sign in to rate this
It worked!
Thanks again Shay,
Steve
Be the first to rate this
|
Sign in to rate this
here is the target payload variable
Be the first to rate this
|
Sign in to rate this