Skip to Content
Author's profile photo Jerry Wang

How to make Code List Restriction work when control field and restricted field are not on the same BO

Customer has requirement that code list for field Function in Contact creation page should be restricted based on the role code in Account TI.
Technically the control field above is modeled in this field as below: ( in BO BusinessPartner )
And the restricted field Function is in another BO: BusinessPartnerRelationship
In this case it is not possible to use the RoleCode field to control the Function field.
Fortunately besides Business Field, it is supported to use an extension field to perform CLR( Code List Restriction ) as well.
Here below are detailed steps:
1. Create an extension field with indicator data type on Root node of BusinessPartnerRelationship:
2. Create an AfterModify event implementation to manually copy the value of RoleCode from BusinessPartner BO to the indicator extension field:
import ABSL;
import AP.FO.BusinessPartner.Global;

var bpID = this.ContactPerson.ToRoot.FirstBusinessPartner.InternalID;
var queryByID = Customer.QueryByIdentification;
var queryByIDParameter = queryByID.CreateSelectionParams();

queryByIDParameter.Add( queryByID.InternalID, "I", "EQ", bpID );
var result = queryByID.Execute(queryByIDParameter);
var first = result.GetFirst(); 

var common = first.Common.GetFirst();
var RoleCode = common.ToRoot.CustomerRole.RoleCode.content;

if( RoleCode == "BUP002" ){ // prospect
	this.ZRoleIndicator = true;
}
else{
	this.ZRoleIndicator = false;
}
3. Add this extension field to Quick Creation UI via Extensibility Explorer:
4. Now it is ready to create a code list restriction based on this indicator extension field: it is now available in Control Field drop down list:
Just define corresponding value for Prospect ( indicator equals to true ) and Customer ( indicator equals to false ):
And it works in the runtime: in contact creation page, only a subset of specified entries in CLR maintenance UI is displayed.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Nik Bach
      Nik Bach

      Hi Jerry,

      it is a nice tutorial. I have followed your steps on LEAD by checking the employee`s SalesOrg assignment to control the available values in "Source" field. Reason - different sales orgs have got different sources. Maintaining on business role level is simply too much.

      Well implementation is pretty the same.

      Instead of taking the quick create, I used the TI screen.

       

      The issue is, that code list restriction seems not to trigger at all. Any idea if it is deprecated?

       

      I mean, the indicator is set for sure. I even saved the lead.

      Any ideas on that?

       

      Thanks

      Nik