When is that relevant?
Sometimes you might need to look through the explanation for a specific substring to perform certain acts in the custom function or make conditions. For such cases, a little manipulation is needed to be done on the explanation.
How to get the explanation?
To get the explanation into the custom function, use the following command:
"explanation = ctx.get_pricing_explanation()" This will assign the explanation from the UI to the explanatory variable.
How to use the explanation?
To use it correctly, it's needed to first decode into utf-8 format.
This will be done using deco_exp=explanation.encode('unicode_escape').decode('utf-8').
Please note, It's recommended to assign the decoded explanation to another variable in case you want later to send an edited explanation using the ctx.set_explanation(string)
After the explanation is decoded, we must ensure it's in all lower cases. For that, we use the command deco_exp=deco_exp.lower(),
Now we have a variable that is decoded as expected and has lower cases, and on it, we can perform actions such as search for specific substrings.
Comments
0 comments
Please sign in to leave a comment.