cancel
Showing results for 
Search instead for 
Did you mean: 

Can I delete any Resource line from product tree by ServiceLayer?

mucipilbuga
Participant
0 Kudos

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:)

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

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

mucipilbuga
Participant
0 Kudos

Dear Ankit CHAUHAN,

Thanks a lot. I will check the post.

But what about deleting any line from product tree?

Regards,

Mucip:)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

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

mucipilbuga
Participant
0 Kudos

Hi,

I see. If I want to delete any line from the product tree. I will save product tree and details again but without deleted line?...

 

Regards,

Mucip:)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi mucipilbuga,

Yes, while updating, do not include the line which you want to delete.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

mucipilbuga
Participant
0 Kudos

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:)

 

 

 

Answers (0)