How To Get the value of Global Defaults of a parameter from within a CB Plugin (aka hook)

Overview

This article shows how to get the global default value of a parameter within a CB plug-in

Considerations

You have a parameter name ‘test_test' with a global default as ‘my value’ configured in the UI like:


Procedure

Step 1 Import required modules

from behavior_mapping.models import CustomFieldMapping

Step 2 Get the CustomFieldMapping of the parameter like:

  1. cfm=CustomFieldMapping.objects.get(custom_field__name='test_test', default__isnull=False)

Step 3 Get the default

  1. cfm.default

Out[11]: <CustomFieldValue: test = myval>

Step 4 Get the default value:

  1. cfm.default.value

Out[12]: 'myval'

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.