Reltio Connect

 View Only
  • 1.  email notification to a list of users in case change request is rejected.

    Reltio Employee
    Posted 01-09-2024 09:29

    =================

    Moving the discussion from I360 community to here on behalf of Sanjay Kumar

    ================

    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
    ------------------------------


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


  • 2.  RE: email notification to a list of users in case change request is rejected.

    Reltio Employee
    Posted 01-19-2024 09:44

    What is the version of Workflow API that you use?
    Does the NullPointerException happen when you run the custom code locally or on the production deployment?



    ------------------------------
    Yury Timofeev
    Product Owner of the Workflow
    Reltio
    ------------------------------



  • 3.  RE: email notification to a list of users in case change request is rejected.

    Reltio Employee
    Posted 01-19-2024 09:55

    @Sanjay Kumar ?



    ------------------------------
    Chris Detzel
    Director of Customer Community and Engagement
    Reltio
    ------------------------------