Saturday, January 7, 2012

Disabling MDM validations for OOTB business objects

Consider a scenario where we need to provide the following fields in the request object
2)Phone number/Email -Contact Method
3) Attach Privacy Preferene type/reason ,value etc to the contact methods listed above
The object that will come to our mind are
Yes you are correct on that.
All these objects can be included in TCRMContractBObj. I decided to create a custom MDM txn(say addMyPreferenceTxn)- (I am using MDM8.5) with TCRMContractBObj as the request object.The response objects doesn't matter for this scenario.
I generated the code,and wrote my logic in the component class which got generated.
When I am about to test the code, it throwed the following errors at my face .

Currency type,ContractStatusType ,Role Type are mandatory. There are a few OOTB external/internal validation on the TCRMContractBObj which makes it mandatory. But for my custom addMyPreferenceTxn I dont want the consumer of the service to provide any dummy values for these 3 fields.

When you genrate the code you will get an EJB project which contains the following class.
Open that class ,there will be a method  public DWLResponse addMyPreferenceTxn(TCRMContractBObj theBObj) throws DWLBaseException

Here is where you are going to put the extra piece of code to bypass the validation logic.
This piece will be executed after the validations happens but before it enters your component.

I am providing the  code outline for the  addMyPreferenceTxn method.

DWLTransaction txObj = new DWLTransactionPersistent("addMyPreferenceTxn", theBObj, theBObj.getControl());
        DWLResponse retObj = null;
        retObj = executeTx(txObj);
        Vector vector = retObj.getStatus().getDwlErrorGroup();
        //Create an iterator for the vector ,iterator through it.

                 DWLError error = vector.get(); 
                //The component ids for currncy typ,role type,status type etc..
                if(error.getComponentType() == 2000 || error.getComponentType() == 2001 || error.getComponentType() == 2002) {

                    //Remove from the iterator.       
        //It will be zero if all the validations where success.If it failed for eg:PrivPrefType is empty ,the
        //vector still contains data and that will be returned back.
        if(vector.size() == 0 ) {               
            DWLStatus status = new DWLStatus();
            try {
                retObj = handleAddMyPreferenceTxn(theBObj);
            } catch (Exception e) {
        return retObj;

 Hope that helps!.

1 comment:

  1. Hello Nikkie, This is Nidheesh..

    i have added a party successfully in MDM and now i am trying to update the party with new partyAddress. That means i am endadating the existing partyAddress and add another partyAddress with start date. While doing this i am getting an error as 'The following is required : PrivPrefType' But in the request XML PrivPrefType is presend for both TCRMAddressPrevPref object and TCRMRoleLocation object. could you please help me to solve the issue??