10 Replies Latest reply on May 10, 2021 12:17 AM by Shirshendu Deb Roy

    Update the null columns in BES External Call

    Shirshendu Deb Roy Seasoned Veteran

      Hi Team,

       

      By default, the BES JSON document doesn't return (GET method's response) those columns which are null.

       

      For example, if I hit the below URL:

       

      http://52.87.212.245:8080/cmx/cs/MDM204-LS_PT_EV/VW_Organization/510001/Communication

       

      then only those columns which are not null, will be loaded up in the JSON document (response).

       

      Now, if I want to update the null columns with one concrete value with the help of the external call, but it's not working because the input JSON document doesn't even contain the null columns then I won't be able to update it either with the help of codes.

       

      Need your help on this to update these type of columns.

       

      Message was edited by: Shirshendu Deb Roy

        • 1. Re: Update the null columns in BES External Call
          Sathiesh M Guru

          In a typical BES external implementation, data on the UI is readily available for the external call as inputSDO parameter. Only for data that is not available in UI say a different Entity record, you may need to perform ReadEntity call (sample code at bottom).

          Once you have all the information, you should be able to add/modify the inputSDO fields which gets finally saved to database. The fields availability is based on the BE config and not the data is blank or not. If the config has the field it can always be populated. A small difference in case you want to add a new Child record, then you would need to use the createDataObject method.

           

          Sample inputSDO use:

              @Override

              public DataObject process(HelperContext helperContext, DataObject inputSdo,

                                        Map<String, Object> inParams,

                                        Map<String, Object> outParams) throws StepException {

                    DataFactory dataFactory = helperContext.getDataFactory();

                      // make sure "Person" SDO has at least one "Address" item

                      List<?> list = inputSdo.getList("Person/Addresses/item");

                      if ((list == null) || list.isEmpty()) {

                          String personId = inputSdo.getString("Person/rowidObject");

           

          Sample new child record creation:

          LOG.info("new telephone");

          phoneDataObject = root.createDataObject("TelephoneNumbers");

          phoneDataObject.createDataObject("item");

           

          Sample ReadEntity call:

          public static DataObject readExistingRecord(CompositeServiceClient client, ExternalCallRequest externalCallRequest,

          HelperContext helperContext, String businessEntity, String rowid) {

          if (rowid != null && !rowid.trim().isEmpty()) {

          DataFactory dataFactory = helperContext.getDataFactory();

          DataObject readEntity = dataFactory.create(ReadEntity.class);

          DataObject coFilterNode = readEntity.createDataObject(IAppsConstant.PARAMETERS).createDataObject(IAppsConstant.CO_FILTER).createDataObject(IAppsConstant.OBJECT);

          coFilterNode.set("name", businessEntity);

          coFilterNode.set("depth", 10);

          DataObject key = coFilterNode.createDataObject("key");

          key.set("rowid", rowid.trim());

          List<String> recordStates = new ArrayList<String>();

          recordStates.add(IAppsConstant.ACTIVE);

          recordStates.add(IAppsConstant.PENDING);

          coFilterNode.setList("recordState", recordStates);

           

          try {

                          String appName = "e360";

                          CallContext callContext = new CallContext(externalCallRequest.getHeader().getOrsId(), appName + "/" + externalCallRequest.getHeader().getUser(), (byte[]) null);

          DataObject readBEResponse = client.process(callContext, readEntity);

           

          return readBEResponse.getDataObject(IAppsConstant.OBJECT);

           

          } catch (CompositeServiceException e) {

          LOG.error("Error while reading existing records for Business entity " + e.getMessage());

          e.printStackTrace();

          }

          }

          return null;

          }

          • 2. Re: Update the null columns in BES External Call
            Shirshendu Deb Roy Seasoned Veteran

            Hi Sathiesh, Could you please provide one sample Write Entity class?

            • 3. Re: Update the null columns in BES External Call
              Shirshendu Deb Roy Seasoned Veteran

              Hi Sathiesh,

              I have tried to implement the Read Entity BES call but it is still unable to read those columns which are null and it's throwing java.lang.NullPointerException when trying to read such columns.

               

              Please let us know if this is a limitation of this product.

              • 4. Re: Update the null columns in BES External Call
                Mayur Saxena New Member

                Hi,

                Below is the Sample for WriteEntity:

                <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

                xmlns:urn="urn:cs-ors.informatica.mdm"

                xmlns:urn1="urn:co-base.informatica.mdm"

                xmlns:urn2="urn:cs-base.informatica.mdm"

                xmlns:urn3="urn:co-ors.informatica.mdm"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                   <soapenv:Header/>

                   <soapenv:Body>

                      <urn:writeEntity>

                         <urn:object xmlns:urn3="urn:co-ors.informatica.mdm" xsi:type="urn3:Person">

                            <urn3:Person label="Person">

                               <urn3:partyType>Person</urn3:partyType>

                               <urn3:lastName>test1</urn3:lastName>

                               <urn3:middleName>test1</urn3:middleName>

                               <urn3:firstName>test1</urn3:firstName>

                            </urn3:Person>

                            <urn3:changeSummary create="#/urn:writeEntity/urn:object/urn1:Person" logging="false" xmlns:sdo="commonj.sdo">

                            <urn:object sdo:ref="#/urn:writeEntity/urn:object" sdo:unset="Person"/>

                            </urn3:changeSummary>

                         </urn:object>

                         <urn:parameters>

                            <urn:systemName>Admin</urn:systemName>

                         </urn:parameters>

                      </urn:writeEntity>

                   </soapenv:Body>

                </soapenv:Envelope>

                 



                Regards,
                Mayur

                • 5. Re: Update the null columns in BES External Call
                  Shirshendu Deb Roy Seasoned Veteran

                  Hi Mayur,

                  This is a SOAP operation example and here you are creating a new person entity record.

                  I am looking for java code example for Write Entity and I want to update one column of an existing record.

                   

                  Do you have any example like this?

                  • 6. Re: Update the null columns in BES External Call
                    Sathiesh M Guru

                    I gave ReadEntity sample only because you tried to do GET call. But not sure what's your use-case and sequence of operations you need to perform in External call.

                    Simply the inputSDO if got the field already you can use inputSdo.setString("VW_Organization/Communication/phone_num"); method

                    Or if doesn't exist create it using

                    commDataObject = root.createDataObject("Communication");

                    commDataObject.createDataObject("item");

                     

                    Most probably you wont need ReadEntity service and definitely not WriteEntity service. Try to make use of inputSDO as much as possible

                    • 7. Re: Update the null columns in BES External Call
                      Shirshendu Deb Roy Seasoned Veteran

                      Hi Sathiesh,

                       

                      My use case is to read one field and update it with a value if it's null or else leave it as it is.

                       

                      To do that, I decided to make use of inputSDO object but it is of no use because it doesn't contain those fields which are currently set to null in the database. It will only hold those columns which are presently not null.

                       

                      I have implemented one read entity call as well but it still doesn't contain that particular column (because it is null) in the response object. It's throwing the null pointer exception. Therefore, I tackled the null pointer exception and assumed that the field is null, however, I still need to update it for the existing record with the help of Write Entity call.

                       

                      So, if you can provide one update column example through write entity BES Call, it would be really helpful.

                       

                      I am not sure if anyone has already tried to do something like this before, because this question (inability to read the null columns) should have been raised by now.

                      • 8. Re: Update the null columns in BES External Call
                        kunal pandit Guru

                        Hi Shirshendu,

                         

                        You may probably be running into a known issue where MDM-36602 - Unable to update a Number field to NULL with ORS Specific APIs. The BE APIs are based on ORS specific APIs.

                         

                        Workaround is to use a regular PUT API call, if you want to update a value specifically to NULL.

                         

                        thanks

                        Kunal

                        • 9. Re: Update the null columns in BES External Call
                          Sathiesh M Guru

                          Assuming this field is part of BE layout already, you don’t need ReadEntity or WriteEntity calls. Simply check for that column in inputSDO, if NPE thrown handle it and proceed with createDataObject method to populate that field.

                           

                          Sathiesh M  |  Infa GCS-MDM

                          • 10. Re: Update the null columns in BES External Call
                            Shirshendu Deb Roy Seasoned Veteran

                            Hi Sathiesh,

                            As I mentioned earlier as well, the field is already part of BE layout, but that field is not part of inputSDO, because it holds null value and therefore, the inputSDO doesn't contain that field.

                             

                            If I try to read the field, it will throw null pointer exception and that's exactly what is happening although, it is not good approach (by handling the null pointer exception and then assume if the column holds null value).