Skip to main content

Capture Case Resolution data before reopening case using C#

 When we reactivate cases, the old case resolution record is set as cancelled and a new case resolution record is created, before you re open the case, you can actually store case resolution data, which you can later use when you re-close the case.

 

Solution:

Below is the code to get case resolution data 

 

  private void GetCaseResolutionData()

        {

            string resolutiondata = null, Remark=null;

            try {

                EntityReference currentEntity = (EntityReference)context.InputParameters["Target"];

                Entity Case = service.Retrieve("incident", currentEntity.Id, new ColumnSet(new string[] {"statuscode"}));

                Guid CaseID = currentEntity.Id;

                string ResolutionType = Case.FormattedValues["statuscode"];  //case resolution dropdown formatted value

                int Resolutionvalue = ((OptionSetValue)Case["statuscode"]).Value; //case resolution option set value

                QueryExpression query = new QueryExpression("activitypointer");

                query.ColumnSet.AddColumns("subject");

                query.ColumnSet.AddColumns("description");

                query.Criteria = new FilterExpression();

                query.Criteria.AddCondition("regardingobjectid", ConditionOperator.Equal, CaseID);

                EntityCollection results = service.RetrieveMultiple(query);

                trace.Trace("after Query Exprrssion");

                if (results.Entities.Count >= 1)

                {

                      resolutiondata = results.Entities[0].GetAttributeValue<string>("subject"); // resolution saved against the case

                     Remark= results.Entities[0].GetAttributeValue<string>("description"); //remarks saved against case

                } 

 

            

         Code below is to close case again with data saved as per above string

 

            var resolution = new Entity("incidentresolution");

            resolution["subject"] = resolutiondata;

            resolution["incidentid"] = new EntityReference { Id = caseID, LogicalName = "incident" };

            var closeIncidentRequest = new CloseIncidentRequest

            {

                IncidentResolution = resolution,

                Status = new OptionSetValue((int)resolutionType)

            };

            service.Execute(closeIncidentRequest);


Comments

Popular posts from this blog

Get Business Process Flow Stage Id using API Query

Developers may need to get the stage ids of BPF stages in order to use in power automate or JS. Here is a blog that will help. API Query-   https:// CRMURL.dynamics.com/ api/data/v9.0/processstages?$select=stagename&$filter=processid/workflowid eq BPFGuid   Eg: 1) Get the GUID of  Business Process Flow whose stage details you need. Replace below Query with Your CRM URL and BPF GUID. https://Test130.crm.dynamics.com/ api/data/v9.0/processstages?$select=stagename&$filter=processid/workflowid eq 9128E4D1-1234-4852-ABD0-A63A6ECA5C5D   Output:    The output will provide the stage name and ID.

Dynamic, Multiple Recipients of D365 Email in Power Automate

When t he activity parties (TO, From, CC) ae static, we can easily send emails. However here is how we can set the activity party dynamically on the Email.    In above screenshot we can see the Activity party attribute is populated for single value and is static to only a single entity record GUID.   Solution: The create a record of Email message is as below, here we are entering the attributes of activity party, by clicking on "Switch to Input entire array" You will get the Array format, the participationtypemask is TO, FROM,CC while the partyid@data.bind is the email address. Now all you need to do is create a dynamic array, You can use append to array variable action to create an array with participationtypemask as per your requirement. Example: get all users whom you need to send email, append the user id to array. pass this array as input to the Activity Parties field in create an email record.  

Power Automate to Access SharePoint Recycle Bin

Introduction : A ccess Recycle Bin of SharePoint using Power Automate. Steps: Actions: select "Send an HTTP request to SharePoint" Enter the below details: Site Address: Select your site address from the list. Method: GET Uri, Headers: Refer the screenshot below. Pls. Note: Trigger used was When a File is Deleted- SharePoint Connector. Select Action "Parse JSON" In parse JSON, the content is the body of HTTP Response Enter the below Schema: { "type" : "object" , "properties" : { "odata.metadata" : { "type" : "string" }, "value" : { "type" : "array" , "items" : { "type" : "object" , "properties" : { "odata.type" : { "type" : "string" }, "odata.id" : { "type" : "string" }, "odata.editLink" : { "t