Skip to Content

IF Condition does not work

Hello !

Business Requirement: Update only empty fields of an Individual Customer in C4C

Steps in CPI:

  1. Get Individual Data from C4C
  2. Store each Field in a Property
  3. Message Mapping using a Script to Get the property value and IF condition
  4. Patch the Individual in C4C

Payload Example of Step 1:

<IndividualCustomerCollection>
<IndividualCustomer>
<GenderCode>1</GenderCode>
<HouseNumber></HouseNumber>
<Email></Email>
<FirstName>Individual</FirstName>
<StateCode></StateCode>
<CustomerID>123456</CustomerID>
<City></City>
<MiddleName></MiddleName>
<County></County>
<Mobile></Mobile>
<StreetPostalCode></StreetPostalCode>
<LanguageCode>EN</LanguageCode>
<MaritalStatusCode></MaritalStatusCode>
<Phone>+33 45656777</Phone>
<TitleCode></TitleCode>
<WebSite></WebSite>
<Street></Street>
<LastName>Last</LastName>
<CountryCode></CountryCode>
<BirthDate/>
</IndividualCustomer>
</IndividualCustomerCollection>

Message Mapping Example for a Field:

This is the Payload after the Message Mapping:

<?xml version="1.0" encoding="UTF-8"?>
<IndividualCustomerCollection>
  <IndividualCustomer>
    <ObjectID>00163E77980F1EDAB1D060334FDA8135</ObjectID>
    <GenderCode>1</GenderCode>
    <LanguageCode>EN</LanguageCode>
    <Phone>+33 45656777</Phone>
  </IndividualCustomer>
</IndividualCustomerCollection>

The Condition in the message mapping is seems to be working only for the false value.

Do you have any idea how to resolve this behaviour? Am I missing anything?

Sriprasad Shivaram Bhat or Morten Wittrock maybe?

Thanks a lot for your answer.

Regards.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jul 16, 2020 at 05:52 AM

    Hello Nadir,

    I would suggest you to first enable trace and check whether property is getting updated before message mapping step or not.

    After that instead of putting equals in graphical message mapping add this logic in getproperty custom function only with additional logic to get check whether property value exist and not null then pass true else pass false.

    Regards,

    Sriprasad Shivaram Bhat

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Sriprasad Shivaram Bhat

      Thanks for your answer. Just before the Message Mapping, I added a Content Modifier to:

      • Store all the properties from the Get Call
      • Store the Initial Body which contains all information

      Many of the properties are empty, the goal is to replace these empty values by the values from the initial body. So the message mapping is to do so.

      How can I do the second part?

      Please find the GetProperty custom function below:

      import com.sap.it.api.mapping.*;
      import com.sap.it.api.mapping.MappingContext;
      
      
      def String getProperty(String property_name, MappingContext context) {
          def propValue= context.getProperty(property_name);
          return propValue;
      }

      Thanks,

      Nadir

  • Posted on Jul 16, 2020 at 09:53 AM

    Hi all,

    I updated the iFlow and change all the logic in the message mapping. it is working now.

    Thanks,

    Nadir

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.