We want the user to enter their email address and select the "region" of the identity they want to create in the deduplication feature when creating a new identity.
Then, in the create feature, the "departement" attribute will be calculated based on the information entered in the deduplication feature.
For example:
In the deduplication feature, the user enters "Ile-de-France" in the "region" field.
In the create feature, the user can choose "91", "92", "93", "94", etc., in the "departement" field, but will not see a list of all possible departments (only those that include the "Ile-de-France" region).
How can we implement this use case?
Data model
2 replies
Best reply by Anouar AGNAOU
Hello Hassan,
Unfortunately, due to a deliberate product limitation, it's not possible to directly use the value of an attribute from one feature (deduplication) in the scope of another attribute within a creation feature.
However, I have two possible solutions depending on the user experience and functional logic you're aiming for.
Solution 1: Rely on a single attribute (Department)
This approach involves using only the Department attribute without directly exposing the Region attribute. Since there is an organizational dependency (a region is always the parent of a department), the idea is to automatically calculate the region based on the selected department.
That said, displaying all departments might not meet the initial need. To address this, you could enforce the prior selection of the region to dynamically filter the department list based on the chosen region.
I’ve attached a demonstration video and the necessary code for this solution.
Note : In the demonstration video, the label "Parent Organization" will correspond to "Region" in your case.
Code to Inject : Code is available below the solution 2
Solution 2: Using Choice Rule
This solution allows you to maintain the initial UX logic while using both the Reqion attribute in the deduplication feature and the Department attribute in the creation feature. It leverages Groovy script Choice Rules to dynamically build the list of values based on another attribute.
Important Prerequisite: The objects involved must be modeled as resources. If regions and departments are currently modeled as organizations, they will need to be replicated as resources for this logic to apply.
However, since your actual use case involves ministries and operators (which are already resources), this solution would be perfectly suitable.
How It Works based on my test (available in the screen recording) :
A testAttribute is exposed in the deduplication feature.
A second testAttribute2 is configured in the creation feature with a Groovy script Choice Rule configured on the testAttribute2 attribute definition.
The Groovy script accesses the testAttribute value to dynamically generate the expected dropdown list.
I've also attached a demo video for this solution.
I hope one of these solutions fits your needs 😃
Best regards,
Anouar
Attachement:
Code to Inject Solution 1 :
<widgetid="organization"xsi:type="ctdbum:AttributeEditorWidgetType"><hidden>false</hidden><config><lockedInUi>false</lockedInUi><mode>READ_WRITE</mode><override>true</override><editor><editWidgetxsi:type="ctdbum:AdvancedObjectReferenceEditWidgetType"><hidden>false</hidden><config><conditional>false</conditional><popupAttributes><attribute>id</attribute></popupAttributes><search><actions/><allowExport>false</allowExport><columns><column><attribute>true</attribute><dataKey>id</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>true</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>true</sortable><sorted>false</sorted><timeZoneStrategy>BROWSER</timeZoneStrategy><type>general</type></column><column><attribute>true</attribute><dataKey>organizationName</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>false</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>true</sortable><sorted>false</sorted><timeZoneStrategy>BROWSER</timeZoneStrategy><type>general</type></column><column><attribute>true</attribute><dataKey>parentOrganization</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>false</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>false</sortable><sorted>false</sorted><timeZoneStrategy>BROWSER</timeZoneStrategy><type>excerpt</type></column></columns><rowClickActions/><additionalSearchAttributes/><displayFrozenOperators>true</displayFrozenOperators><frozen>NO</frozen><modes><mode>MULTICRITERIA</mode></modes><objectReferences><objectReference><attribute>parentOrganization</attribute><editWidgetxsi:type="ctdbum:AdvancedObjectReferenceEditWidgetType"><hidden>false</hidden><config><conditional>false</conditional><popupAttributes><attribute>id</attribute></popupAttributes><search><actions/><allowExport>false</allowExport><columns><column><attribute>true</attribute><dataKey>id</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>true</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>true</sortable><sorted>false</sorted><timeZoneStrategy>BROWSER</timeZoneStrategy><type>general</type></column><column><attribute>true</attribute><dataKey>organizationName</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>false</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>true</sortable><sorted>false</sorted><timeZoneStrategy>BROWSER</timeZoneStrategy><type>general</type></column><column><attribute>true</attribute><dataKey>parentOrganization</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>false</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>false</sortable><sorted>false</sorted><timeZoneStrategy>BROWSER</timeZoneStrategy><type>excerpt</type></column><column><attribute>true</attribute><dataKey>organizationType</dataKey><dataType>string</dataType><dateFormat>DAY_MONTH_YEAR_LONG</dateFormat><ellipsis>false</ellipsis><hidden>false</hidden><sortAs>ALPHA</sortAs><sortDirection>ASC</sortDirection><sortable>true</sortable><sorted>true</sorted><type>general</type></column></columns><rowClickActions/><additionalSearchAttributes/><displayFrozenOperators>true</displayFrozenOperators><frozen>NO</frozen><modes><mode>SIMPLE</mode><mode>MULTICRITERIA</mode></modes><objectReferences/></search><displayPopup>true</displayPopup><scopeobjectKind="ORGANIZATION"type="EXPRESSION"xsi:type="ctd:DynamicObjectScopeType"><searchExpression/><objectTypes><objectType>location</objectType></objectTypes></scope></config></editWidget></objectReference></objectReferences><searchExpression><search:Propname="parentOrganization"op="EQUALS"/></searchExpression></search><displayPopup>true</displayPopup><scopeobjectKind="ORGANIZATION"type="RULE"xsi:type="ctd:DynamicObjectScopeType"><rule><script><![CDATA[
import com.memority.toolkit.core.api.search.expression.SearchExpression
import _libs_.featureAccessPolicy$scope$library.Main
import com.memority.toolkit.rule.api.groovy.transform.Lib
import groovy.transform.Field
// The searchExpression is the joint of all rights scopes of the user
@Lib
@Field
final _libs_.featureAccessPolicy$scope$library.Main SCOPE
def fullExpr = ~expr {}
if (SUBJECT.rights.any { it.name == "adm.administrator-features" }) {
fullExpr |= expr { enabled.eq(true) }
}
return fullExpr
]]></script></rule><objectTypes><objectType>department</objectType></objectTypes></scope></config></editWidget></editor></config><attributeId>organization</attributeId></widget>