Question

messaging between detail schema and Edit page

Hi Team,

I have a multi select lookup detail called 'Tags' in the Case Page. My requirement is When status changed to resolved in case system will check if case have any tags if not multiselect lookup selection modal window should be displayed to select tags.

 

My Approach:

My approach for this is subscribe to javascript onchange event and check if it have any tags with esq and if it has no tags It will publish message to the detail schema, when recieved the message system will display multiselect lookup selection modal window.

 

Code in CasePage:

 

messages: {

            "caseResolvedOpenTags": {

                mode: Terrasoft.MessageMode.BROADCAST,

                direction: Terrasoft.MessageDirectionType.PUBLISH

            }

        },

    methods: {

            onStatusChanged: function(){

                this.callParent(arguments);

                var args = {

                    caseId: this.get("Id")

                };

                var moduleIds = this.getModuleIds();

                moduleIds.push(this.sandbox.id);

                this.sandbox.publish("caseResolvedOpenTags", args, moduleIds);

            }

        },

Code in detail schema:

define("GlbCaseInTagDetail", [], function() {

    return {

        entitySchemaName: "GlbCaseInTag",

        messages: {

            "caseResolvedOpenTags": {

                mode: Terrasoft.MessageMode.BROADCAST,

                direction: Terrasoft.MessageDirectionType.SUBSCRIBE

            },

        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,

        methods: {

            init: function(){

                this.callParent(arguments);

                

                this.sandbox.subscribe("caseResolvedOpenTags", function(args){

                    this.openLookupWithMultiSelect(true);

                }, this, [this.sandbox.id]);

            },

            onOpenTags: function(args){

            //var caseId = args.caseId;

            window.alert("messageSubscribed");

            this.openLookupWithMultiSelect(true);

            }

        },

        }

    };

});

 

Problem: 

I have got no errors but I am not able to hit the handler method(onOpenTags). I have tried both Broadcast and PTP messages. I think I did something wrong with the message tags. Can someone help please?

 

Is there any other easy way to handle this requirement?

Like 0

Like

4 comments

Hi Nagaraju,

 

And what happens if you specify the onOpenTags method as a handler for the received caseResolvedOpenTags message (inside the init method of the detail)?

 

Best regards,

Oscar

Hi Oscar,

 

Thanks for reply. I used below code as well. It did not work either.

this.sandbox.subscribe("caseResolvedOpenTags", this.onOpenTags, this, [this.sandbox.id]);

Could it be that the last parameter for sandbox Id doesn't match? For the message to be received, both the sender and receiver need to use the same Id for that parameter. You could try by hardcoding a value for that parameter, such as "MySandboxMessageId" to see if it's received. Typically, the sandbox id for the detail will have the same sandbox id as the page, but with an added "_detail_UsrTheDetailSchemaName" - which means they won't match. 

For a detail that needs to communicate with the parent page via sandbox, I use the following on the detail to get the page's sandbox Id and then use this for that last parameter (for the sandbox call on the detail, for the page, I just use this.sandbox.id):

getPageSandboxId: function() {
	var idx = this.sandbox.id.indexOf("_detail_" + this.values.SchemaName);
	return this.sandbox.id.substring(0, idx);
}

Hope this helps. 

Ryan

Ryan Farley,

Thanks for reply Ryan. Using hardcoded string in tags worked for me like below

this.sandbox.subscribe("caseResolvedOpenTags", this.onOpenTags, this, ["PromptLookup"]);

Show all comments