cancel
Showing results for 
Search instead for 
Did you mean: 

How to update product attribute value from a web service on Sap CPQ?

sbslmhmt
Participant
0 Kudos

Hello,

CPQ provides various rest apis but I cound find any to update a product attribute value. Am I missing something?

CPQ Rest Apis

Best regards.

MaxGag
Participant
0 Kudos

Hello sbslmhmt ,

What exactly the goal you want to achieve? You have a configurable product on a quotation and you want to change the value of one of the attribute in the product? Or you want to change the attribute master data?

Thanks

sbslmhmt
Participant
0 Kudos

Hello maxgag2 ,

"You have a configurable product on a quotation and you want to change the value of one of the attribute in the product". This is exacly what I want. I am using a global script as a web service.

https://eusb.webcomcpq.com/customapi/executescript?scriptname=<SCRIPT_NAME>&username=<USERNAME>&pass...;

Quote is loading with no problem. I am able to send attribute name and attribute value to script as well but after that I am lost.

Thank you maxgag2 ,

Best regards.

Accepted Solutions (1)

Accepted Solutions (1)

MaxGag
Participant

Hello,

You can find documentation here: https://help.sap.com/viewer/7fc27540a0f14bd1a10b639117a9d4d7/2108/en-US/5b43a32ab3d34ba8bb9340a7d5f1...

Calling a script from the API is perfect.

In your script you will need to find the best way to get the right quote item. If you already know the line item number you can use x = Quote.GetItemByQuoteItem('lineItemNumber') or you can also loop in the mainItems as the example below and find the right mainItem data to use to get the product you look for. For sure if you have the same product twice in your quotation that will be tricky!!

Thanks

Here's the SAP help solution:

How to inline update configuration of existing quote item?

If configuration of existing main item in the quote needs to be updated, this can be executed inline - without leaving current quote.

Script for changing configuration can be exposed as custom action.

All quote calculations will be executed in the same way as item is manually updated from the configurator.

Script example for updating Maintenance product:

for mainItem in Quote.MainItems:
    if mainItem.ProductName == 'Maintenance':
        mainItem.Edit()
        Product.Attributes.GetByName('Maintenance duration').SelectValue('5-YEARS')
        Product.Attributes.GetByName('Contract Type').AssignValue('Added 5-years contract')
        if Product.Attributes.GetByName('1 Year Support').SelectedValue is not None:
            Product.Attributes.GetByName('1 Year Support').SelectedValue.IsSelected = False
        Product.UpdateQuote()
        break
sbslmhmt
Participant
0 Kudos

Hello maxgag2 ,

You're a life saver, I can't thank you enough.

Best regards.

Answers (1)

Answers (1)

0 Kudos

Hi Mehmet,

Here: https://webcomcpq.com/webapihelp/index#!/Attribute/Attribute_Update (visit this link)

Rest API Endpoint: [PUT]: {CPQ Url}/api/products/v1/attributes/{id}

By using above endpoint you can also update attribute values.

####Values section is highlighted in below payload.

Payload:

{ "Id": 0, "Name": "string", "SystemId": "string", "ExternalId": "string", "Type": "None", "TypeLabel": "string", "ModifiedBy": "string", "ModifiedOn": "string", "ContainsPersonallyIdentifiableInformation": true, "SensitiveData": true, "NumberOfValues": 0, "Autocomplete": { "TableId": 0, "PreselectionFilter": "string", "ShowOnlyDistinctValues": true, "TableColumns": [ { "TableColumnId": 0, "ColumnName": "string", "DisplayLabel": "string", "Rank": 0 } ], "SearchableColumns": [ { "TableColumnId": 0, "ColumnName": "string", "DisplayLabel": "string", "Rank": 0 } ], "DisplayedColumns": [ { "TableColumnId": 0, "ColumnName": "string", "DisplayLabel": "string", "Rank": 0 } ], "IsAutocompleteUsedAsProductAttribute": true }, "Measurement": { "MeasurementId": 0 }, "Container": { "PresentResultsOfProductSearch": true, "MaxContainerRows": "string", "MinContainerRows": "string", "EnablePaging": true, "DefaultNumberOfRows": 0, "Actions": { "AddNewRow": true, "OpenNewConfigurator": true, "DeleteRow": true, "CopyRow": true, "AllowMultipleCopy": true, "ReorderRows": true, "EditRow": true }, "Properties": [ { "Id": 0, "Name": "string", "Formula": "string", "DataType": 0, "DecimalPlaces": 0, "CalculationRank": 0, "IncludeInJSON": true } ], "Validations": [ { "Id": 0, "Name": "string", "Message": "string", "ValidationFormula": "string" } ], "Products": [ { "Id": 0, "SystemId": "string", "Version": "string", "Name": "string", "MinRows": "string", "MaxRows": "string" } ], "Columns": [ { "Id": 0, "Name": "string", "HeaderLabel": "string", "FooterLabel": "string", "Width": 0, "Height": 0, "Total": 0, "Formula": "string", "DisplayRank": 0, "CalculationRank": 0, "DataType": 0, "DecimalPlaces": 0, "ColumnType": 0, "DisplayType": 0, "SelectedAttributeId": 0, "SelectedAttributeValues": [ { "Id": 0, "ValueCode": "string", "Value": "string" } ], "IsSelectedAttributeAutocomplete": true, "IsSelectedAttributeQuoteTableAutocomplete": true, "CalculationFormula": "string", "AlwaysIncludeInKOContext": true, "ContainsPersonallyIdentifiableInformation": true, "SensitiveData": true, "Permissions": [ { "ColumnId": 0, "UserTypeId": 0, "Value": "Hidden" } ], "SelectedPermissions": { "Editable": { "Id": 0, "Permissions": [ 0 ] }, "ReadOnly": { "Id": 0, "Permissions": [ 0 ] }, "Required": { "Id": 0, "Permissions": [ 0 ] }, "Hidden": { "Id": 0, "Permissions": [ 0 ] } }, "DefaultUserTypePermission": "Hidden" } ] }, "Values": [ { "Id": 0, "ProductId": 0, "RefProductDisplayName": "string", "ValueCode": "string", "Value": "string", "SystemId": "string", "Rank": 0, "Unit": 1, "BillingPeriod": 1 } ] }

sbslmhmt
Participant
0 Kudos

Hello mpr923,

Thank you for your answer but is't this for updating attributes values? What I would like to do is change selected value of an attribute on a product.

Best regards.