How to set attibutes in catalog items by processing other attributes values, using custom script.
I am working on project, needs to create a rule using custom script in configurator. I have to set an attribute's value by processing 3 other attribute's value in catalog item.
So, I need following:
> fetch the values of other attributes.
> Set the value of a attribute.
Please help me out.
Hi Vineet Tanwar, I would recommend using the standard "conditions" & "actions" operations within the Rule UI if possible because the custom script may change the behavior of other features within Threekit in unexpected ways. However you can find documentation on the APIs used for custom scripts here: https://community.threekit.com/hc/en-us/articles/4406068592539
For example you can set an attribute's
value by using the following:
Where 'Color' is the attribute name and 'Blue' is the desired value
We also have an additional documentation page with more information about custom scripts, including a working example here: https://community.threekit.com/hc/en-us/articles/4405866601243-Example-Custom-Script
Vineet Tanwar if you're just setting the value of an attribute based on other attributes, a data table lookup should work just fine.
You can set up a data table with each column header as the name of your attributes, and each row will be a representation of your attributes combinations (IDs for reference attributes, strings for strings).
In your Catalog Item rule you won't need a condition since those will be in the query parameters of your action.
Just select the attribute you want to set in your action, your operator will be a data-table query. You can select the column you want to target to set the value of your attribute, and your "query parameters" will match the input attributes to the corresponding columns.
@..., thanks for replying.
But actually it would not work for me, as I also needs to write custom script for calculating the value of my attribute.
So I think, simple if-else condition would not work for me
Hi Vineet - have you found our example custom script documentation to be helpful at all? In a custom script you should be able to retrieve the current configuration by calling the following in your script:
From there you should be able to perform the logic you need and then set the configuration with the proper values. Let me know if this is helpful or if I can provide some more help.
Please sign in to leave a comment.