Topic
  • 1 reply
  • Latest Post - ‏2018-05-18T12:29:20Z by Cloudhu
Cloudhu
Cloudhu
2 Posts

Pinned topic Related Cases in Case details page

‏2018-05-18T07:57:50Z |

Hello! I've tried following Dave's advice in a post about related cases, a script on the work details page and it works, but I want to add it to the case details page and it doesn't work, I don't know how to put it, I need to fix it, please could you help me with this. I'm new to Case Manager and the version I'm testing is 5.2.1.6. 
I tried following Dave's advice with the following code, but without success:

var solution = this.solution;
var params = {};
var self = this;

/* This is good practice. Makes reusing scripts much easier */
var prefix = solution.prefix;

params.ObjectStore = solution.getTargetOS().id;

var custID = payload.caseEditable.propertiesCollection[prefix+"_NdeExpediente"].value;
console.log ("Nº de Expediente: ",custID);
var caseObj = payload.caseEditable.icm.CaseEditable.caseObject;

/* The following call ensures that the case data is loaded before we go try and get the case ID */

caseObj.retrieveCachedAttributes(function(caseObject) {
    var caseID = caseObject.caseIdentifier;

    /* Find all of these */
    var criterion1 = new ecm.model.SearchCriterion({"id": prefix+"_NdeExpediente", "name" : "Nº de Expediente", "selectedOperator": "STARTSWITH", "defaultOperator": "STARTSWITH", "dataType": "xs:string"});
    criterion1.value = custID ;
    criterion1.defaultValue = custID ;
    criterion1.setValues( [custID]);

    /* But omit this one */
    var criterion2 = new ecm.model.SearchCriterion({"id": "cmAcmCaseIdentifier", "name" : "Title", "anded": true, "selectedOperator": "NOTEQUAL", "defaultOperator": "NOTEQUAL", "dataType": "xs:string"});
    criterion2.value = caseID;
    criterion2.defaultValue = caseID;
    criterion2.setValues( [caseID]);

    params.criterions = [criterion1, criterion2];
    params.CaseType = ""; /* all case types */
    params.solution = solution;

    var searchPayload = new icm.util.SearchPayload();

    searchPayload.setModel(params);

    searchPayload.getSearchPayload(function(payload) {
        self.onBroadcastEvent("icm.SearchCases", payload);
    });
});

 

Could you please help me?

 

  • Cloudhu
    Cloudhu
    2 Posts

    Re: Related Cases in Case details page

    ‏2018-05-18T12:29:20Z  

    Hello! I have already managed to adapt the script; I detail it below in case it is useful for someone and so that nobody wastes time trying to help me. I have followed these steps:

     

    • Add a case list widget to your Case Details page
    • Use the wiring settings to disable the Select Case broadcast event. This ensures the case list does not interfere with other page widgets like the Case Infomation
    • Add a Script Adapter widget to the hidden page area
    • Enter the following script in the Script Adapter
    • Wire the inbound event of the Script adapter from the Page Container's "send case information" event
    • Wire the outgoing event of the Scrpt adapter to the widget case list.

     

    var solution = this.solution;
    var params = {};
    var self = this;

    /* This is good practice. Makes reusing scripts much easier */
    var prefix = solution.prefix;

    params.ObjectStore = solution.getTargetOS().id;

    var custID = payload.caseEditable.propertiesCollection[prefix+"_NdeExpediente"].value;
    console.log ("Nº de Expediente: ",custID);
    var caseObj = payload.caseEditable.caseObject;

    /* The following call ensures that the case data is loaded before we go try and get the case ID */

    caseObj.retrieveCachedAttributes(function(caseObject) {
        var caseID = caseObject.caseIdentifier;

        /* Find all of these */
        var criterion1 = new ecm.model.SearchCriterion({"id": prefix+"_NdeExpediente", "name" : "Nº de Expediente", "selectedOperator": "STARTSWITH", "defaultOperator": "STARTSWITH", "dataType": "xs:string"});
        criterion1.value = custID ;
        criterion1.defaultValue = custID ;
        criterion1.setValues( [custID]);

        /* But omit this one */
        var criterion2 = new ecm.model.SearchCriterion({"id": "cmAcmCaseIdentifier", "name" : "Title", "anded": true, "selectedOperator": "NOTEQUAL", "defaultOperator": "NOTEQUAL", "dataType": "xs:string"});
        criterion2.value = caseID;
        criterion2.defaultValue = caseID;
        criterion2.setValues( [caseID]);

        params.criterions = [criterion1, criterion2];
        params.CaseType = ""; /* all case types */
        params.solution = solution;

        var searchPayload = new icm.util.SearchPayload();

        searchPayload.setModel(params);

        searchPayload.getSearchPayload(function(payload) {
            self.onBroadcastEvent("icm.SearchCases", payload);
        });
    });