2024 Apr 08 12:16 AM - edited 2024 Apr 08 12:27 AM
Hi,
I use Service layer with PHP on Linux. In my situation there may be one or more than one Resource lines in the Product Tree. I want to delete specific resource line or lines from Product tree.
I use here and there is ProductTrees function. But I see DELETE function deletes all the Product Tree not the specific lines?
How can I delete specific line from Product tree? I think there is same problem if I want to add new line in to existing Product Tree?!
Regards,
Mucip:)
Request clarification before answering.
Hi mucipilbuga,
Kindly refer to the following blog post: SAP Business One Service Layer: Entity CRUD - Update
The blog discusses about the header B1S-ReplaceCollectionsOnPatch=true which you need to use for your scenario.
This header supports removing an element in the collection.
Header B1S-ReplaceCollectionsOnPatch=true sets the update method as REPLACE, which means the whole content will be replaced and the mismatched old rows will be deleted.
In case of any issue, please do not hesitate to write us back.
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi mucipilbuga,
Question: But what about deleting any line from product tree?
Answer: Header B1S-ReplaceCollectionsOnPatch=true will enable you to do that. The explanation was provided in that reference only.
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
Hi mucipilbuga,
Yes, while updating, do not include the line which you want to delete.
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
Dear Ankit CHAUHAN,
I use below php code but I did not understand where should I add " B1S-ReplaceCollectionsOnPatch=true" statement?
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 59);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIE, $strCookie);
I found the solution. I should add below line and it worked like a charm.
curl_setopt($ch, CURLOPT_HTTPHEADER, ['B1S-ReplaceCollectionsOnPatch:true']);
Regards,
Mucip:)
User | Count |
---|---|
87 | |
13 | |
10 | |
5 | |
4 | |
4 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.