Reltio Identity 360

 View Only
  • 1.  Facing issue in sending Email notificaion on Change Request Reject

    Reltio Partner
    Posted 01-09-2024 09:01

    Hi Team,

    We are trying to send a email notification to a list of users in case change request is rejected. 

    On customization part we are adding some line of code in out of the box java class ChangeRequestReject.java.

    Below is the sample test code where we have added few lines of code(In red) to send email. Build of the code  is successful, when tested locally, we are getting NullPointerException because  NotificationSenderService notificationSenderService variable is initialized to null and hence throws exception when method  [this.notificationSenderService.sendNotification(notification) ] is called. 

    Can anyone please let me know if the approach is corect? If yes, what is the issue in code.

    The BPMN file used for this is the out of the box DCR BPMN.

    package com.reltio.workflow.custom.notifications;

    import com.fasterxml.jackson.databind.ObjectMapper;
    import com.reltio.workflow.activiti.service.ChangeRequestAction;
    import com.reltio.workflow.api.Utility;
    import com.reltio.workflow.api.WorkflowService;
    import com.reltio.workflow.api.actions.Execution;
    import com.reltio.workflow.api.actions.WorkflowAction;
    import com.reltio.workflow.custom.Notification;
    import com.reltio.workflow.custom.NotificationSenderService;
    import com.reltio.workflow.api.rest.ReltioApi;
    import com.reltio.workflow.api.rest.ReltioConstants;
    import com.reltio.workflow.api.rest.ReltioException;
    import com.reltio.workflow.api.rest.Response;
    import com.reltio.workflow.api.rest.beans.ReltioResponse;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    /**
     * Reject data change request
     */
    public class ChangeRequestReject extends ChangeRequestAction implements WorkflowAction {
        public static final Logger logger = LoggerFactory.getLogger(ChangeRequestReject.class);
        // Injectected service
        @WorkflowService
        private ReltioApi reltioApi;
        @WorkflowService
        NotificationSenderService notificationSenderService;

        public void execute(Execution execution) throws Exception {
            logger.info("In ChangeRequestReject class");
            String accessToken = execution.getAccessToken();
            String environmentUrl = execution.getEnvironmentUrl();
            String tenantId = execution.getTenantId();
            String changeRequestUri = getChangeRequestUri(execution);
            String processInstanceId = execution.getProcessInstanceId();
            Notification notification = new Notification(execution.getTenantId());

            notification.setSubject("Your task is Rejected");
            notification.setBody(
                    "<table style=\"width:500px\">" +
                            "<tbody>" +getClass()+
                            "<tr>" +
                            "<td>" +
                            "<img src=\"cid:overdue\" style=\"height:64px; width:64px\" />" +
                            "</td>" +
                            "<td>" +
                            "<p>REMINDER</p>" +
                            "<p>The task created is Rejected. Please take action.</p>" +
                            "</td>" +
                            "</tr>" +
                            "</tbody>" +
                            "</table>");

            //Get Email address of requester

            notification.addTo("firstname.lastname@reltio.com");
            this.notificationSenderService.sendNotification(notification);


            //Reltio Call
            String url = Utility.generateTenantUrl(environmentUrl, tenantId) + "/" + changeRequestUri + "/_reject";
            String responseJson = reltioApi.invokeApi(accessToken, url, ReltioConstants.POST, "");
            ObjectMapper objectMapper = new ObjectMapper();
            Response reltioResponse = objectMapper.readValue(responseJson, ReltioResponse.class);
            if (reltioResponse.getStatus() == null || !reltioResponse.getStatus().equals(ReltioConstants.SUCCESS)) {
                throw new ReltioException(responseJson);
            }

            }

    }



    ------------------------------
    Sanjay Kumar
    Imidia
    Kolkata
    ------------------------------


  • 2.  RE: Facing issue in sending Email notificaion on Change Request Reject

    Reltio Employee
    Posted 01-09-2024 09:31

    Sanjay,

    I moved this to another community to receive answers. This space is only for I360 discussions.

    Link : https://community.reltio.com/discussion/email-notification-to-a-list-of-users-in-case-change-request-is-rejected?ReturnUrl=%2fcommunities%2fcommunity-home%2fdigestviewer%3fListKey%3de5fc8a39-1ac5-46b3-ac74-e703d425015c%26CommunityKey%3dd172c579-9c0e-4e9f-a9bf-fdfeb2fb98ac



    ------------------------------
    Abhradeep Sengupta
    ------------------------------