Posts Tagged ‘successfactors integration’

Successfactors : Adding attachment to MDF Objects via OData

December 3, 2021

In order to upsert into an MDF Object which have attachment, first you have to upsert into the Attachment entity with the base64 encoded File String. This upsert will return the attachment ID. Then retrieve the attachment ID from the response and upsert into the MDF object. The attachment id can be retrieved with XPatch expression like this.

<uri>Attachment(attachmentId=<xsl:copy-of select="substring-after(//atom:entry/atom:content/m:properties/d:key,'Attachment/attachmentId=')"/>)</uri>

After this, Upsert the attachment using this attachment ID wtih payload looking like this:

{
        "cust_ParPaySlip_externalCode": "bbbb",
        "cust_PayrollPeriod": "/Date(1625316265000)/",
        "cust_AttachmentNav": {
            "__metadata": {
                "uri": "Attachment(attachmentId=16840)"
            }
        },
        "__metadata": {
          "uri": "cust_ListPaySlip"
        }
      }

SCPI – Get current time in different Timezone

June 11, 2021

The current datetime can be easily retrieved and assigned to a property or header with the Content Modifier Step like this. Use a Camel Expression like these :

${date:now:yyyy-MM-dd’T’00:00:00’Z’}

or

${date:now:yyyy-MM-dd}

based on the date format you need.

But the problem comes when you need the time in different timezone. For eg, I wanted time in CET, but the camel expression always gives the time in UTC zone. This could be tackled with a groovy script to convert the time into any desired timezone.

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.time.ZonedDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter;

def Message processData(Message message) {    
    
    ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin"));	
    todayTZ = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'00:00:00'Z'"));
    today = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));

    println today
    println todayTZ
    println futureLimitDate

    message.setProperty("todayTZ", todayTZ);
    message.setProperty("today", today);
    return message;
}

That’s it. Println is just for debugging in the IDE console, you can remove it.

Happy Coding. 😉