Hi There,
I am building up the jsdo and then saving the changes back to the database. When this method is called an appserver hit is performed for each row in the kendo grid. How would I be able to send back the jsdo once. I am trying to generate an order and this issue is causing multiple orders to be created instead of one order.
I am using jsdo.add and then when I am finished adding my records, I call jsdo.saveChanges().
TIA
Think you need the batch propertie in the datasource:
Thanks for the reply but unfortunately this did not work for me.
Hello,
>> I am using jsdo.add and then when I am finished adding my records, I call jsdo.saveChanges().
Do you have a Submit method in the Business Entity?
Since you are using the JSDO API directly, then you could use jsdo.saveChanges(true). This would then call the Submit operation in the Business Entity.
I would have expected the batch property to work with the DataSource.
When the batch property is used, the internal code for the JSDO DataSource uses saveChanges(true) instead of saveChanges().
What do you see in the Network tab?
How many requests are sent?
Please let me know how it goes.
Hi Edsel,
The saveChanges accesses my create method, I don't have a submit method. I have never had to use that before.
Without the saveChanges(true), I see an appserver hit for each row being sent back.
If I add saveChanges(true), I get the following error:
Uncaught Error: JSDO: SUBMIT operation is not defined.
Could you please provide me with more info on the submit method?
Thanks in advance.
Hello Meyrick,
Support for Submit was added a couple of releases ago.
Are you using the "BusinessEntity" class in your business entities?
The Submit method looks like the following:
/*------------------------------------------------------------------------------ Purpose: Submit a record Notes: ------------------------------------------------------------------------------*/ @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="true"). @progress.service.resourceMapping(type="REST", operation="submit", URI="/SubmitCustomer", alias="", mediaType="application/json"). METHOD PUBLIC VOID SubmitCustomer(INPUT-OUTPUT DATASET dsCustomer): SUPER:Submit(DATASET dsCustomer BY-REFERENCE). END METHOD.
Please that the annotation for the Submit method uses writeDataSetBeforeImage=true and operation=submit.
You would need to add "BEFORE-TABLE bttCustomer".
You should be able to add this code to an existing Business Entity.
Alternatively, you can generate a new Business Entity with the wizard and specify the usage of the Submit operation.
Information on the Submit operation then would be added to the catalog so that the JSDO would recognize the operation as being defined.
I hope this helps.
Edsel
Hi Edsel,
I have attempted adding the submit operation. If I view my jsdo, the submit operation is there (see below):
"path": "\/SubmitbeOrdLn",
"type": "submit",
"verb": "get",
"params": [{
"name": "dsrntprod",
"type": "REQUEST_BODY"
}]
If I attempt to call the method on the client using saveChanges(true) it fires twice. The first time it fires, it looks fine:
Then straight after the first hit, it fires again:
Now im not exactly sure what the parameters are supposed to be,
but can you see where I am going wrong and possibly point me in the right direction?
TIA
Hello Meyrick,
Did you regenerate the catalog?
Take a look at the annotations. It should say operation="submit".
The entry in the catalog should say type="submit" verb="put".
PUT is used so that you can send JSON data in the body of the request.
The two entries in the Network tab are expected they are for one saveChanges().
The OPTIONS request is the preflight request to checks if the server can accept the actual request.
I hope this helps.
Yes the the operation is submit yet after the war file is generated the verb is get.
What does the annotation for Submit looks like?
What happens if you remove the catalog file (make a backup first) and re-generate it?
You should get an entry for submit like the one in this files: oemobiledemo.progress.com/.../EmployeeSubmitService.json
here is the annotations:
@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="true").
@progress.service.resourceMapping(type="REST", operation="submit", URI="/SubmitbeOrdLn", alias="", mediaType="application/json").
Hi Edsel,
I have removed the catalog and re-generated it and it is still displaying the same parameters for the operator.
Is there possibly something wrong with the annotations?
Can you add the contents of your .cls file to this thread (not just the submit part)?
The annotation looks fine.
What version of OpenEdge / PDSOE are you using? I think that support for Submit was added in 11.4, but it could have been 11.5.
If you use the wizard to create a Business Entity, do you see the option to generate a Submit method?
My guess is that you might be using an old version.
If you are using a version that has support for Submit, then it would need some debugging.
In that case, I would recommend to log a call with Technical Support.
There is a way around... But it is better if you confirm what version you are using and whether you see that it has support for Submit.
I hope this helps.
Thanks Edsel. There is no option to generate a Submit method. We are still using 11.3.2, that is probably my problem. I will try updating the software and take it from there.
This may be a stupid question but is there no way that I can create my own method and call it on the client?
If not, would there not be a way to invoke the update method to do what I need it to do? if so, is there an example for me to look at?
Is there any means possible to for me to do what im wanting to do without upgrading to 11.5?
Yes that is possible. As long as the method is available in your catalog you can invoke it.
The best would be to use Submit because it uses the JSON before-image format and you can send different types of operations: creates, updates, and deletes.
The approach that Ruben mentioned would be to call an invoke the method as an invoke operation.
Another approach would be to try to use the method that you defined as a Submit.
There is a recent option in the JSDO where you can use saveChanges(true) with a backend that does not have the JSON before-image format.
documentation.progress.com/.../
You would need to write the code for method.
For this you would need to manually change get to put in the catalog.
Please give this a try to see if it works with your 11.3. Still, you might want to try upgrading to a more recent version.
(Take a look at the new WebHandlers support in WebSpeed if you upgrade to 11.6.)
I have tried editing the jsdo file and changing the parameters of the submit operation. When I ran it, I could see the request was built up but a 404 error was returned. So now I have tried creating an invoke method. When I run this method on the application, the appserver returns an error and I can see that my invoke is trying to access the Update Method.
Would there need to be something special set up in the business entity?
@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="true").
@progress.service.resourceMapping(type="REST", operation="invoke", URI="", alias="", mediaType="application/json").
METHOD PUBLIC VOID LoadbeOrdLn(INPUT-OUTPUT DATASET dsrntprod):
MESSAGE "Invoke Method".
END METHOD.
I'm accessing the method from the client by doing this:
var jsdo = new progress.data.JSDO('beOrdLn');
jsdo.invoke("LoadbeOrdLn",{});
The invoke approach should work fine. Support for invoke is available since 11.2.
The approach with making the invoke operation work as a Submit could work... but you would be trying to do something that was not available with the 11.3 release.
It would be better to just focus on doing invoke operations.
You would need to update the catalog file to say invoke.
The following thread related to invoke operations might be useful to you: