Defaulting the Email Recipient for Emails in the Actions Dashboard for a Custom Section in Creatio

If you’ve added the Actions Dashboard to a custom section (See previous article Adding the Actions Dashboard to a Custom Section) you might be wondering why the “To” recipient for emails isn’t populating in the Actions Dashboard. This is because the out of the box behavior only populates that if the current section is the Contact section – although there’s a few other sections that will override this for that specific section. In this article we’ll be doing the same and looking at the steps needed to populate the recipient for a custom section you’ve added the Actions Dashboard to.

Since we’ll need to change the behavior of the Actions Dashboard for our own custom section, we’ll need to create a Replacing View Model and select SectionActionsDashboard as the parent. Once we create that, paste in the following code:

 define("UsrMyCustomSectionDashboard", [], function () {
    return {
        methods: {
          	onGetRecordInfoForPublisher: function() {
          		var info = this.callParent(arguments);
              	
          		var contact = this.getMasterEntityParameterValue("UsrContact");
          		info.additionalInfo.contact = contact;

          		var name = contact && contact.displayValue;
          		var email = this.getMasterEntityParameterValue("UsrEmail");
              	
          		if (name && email) {
          			info.additionalInfo.recepient = Ext.String.format("{0} <{1}>; ", name, email);
          		} 
          		else {
          			info.additionalInfo.recepient = null;
          		}
          		return info;
        	}
        },
        diff: []
    };
});

In the code above, you can change the name of the module to suit your needs (instead of UsrMyCustomSectionDashboard). Also, that code will ask the page for your custom section via a sandbox message for the value of the field or attribute named “UsrContact” for a contact and a field or attribute named “UsrEmail” for an email address. You can either change those to match valid columns on your page or just create attributes like the following, then populate them as needed with a contact object and an email address:

attributes: {
	"UsrContact": {
		dataValueType: Terrasoft.DataValueType.CUSTOM_OBJECT,
		type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
	},
	"UsrEmail": {
		dataValueType: Terrasoft.DataValueType.TEXT,
		type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
	}
}

If you’re using attributes, like the ones above, you’ll need to populate them in the onEntityInitialized with valid values to use. However, keep in mind, you don’t need to use attributes like those if you have a contact and email column that already exist for your custom section, in that case, just modify the code in the custom ActionsDashboard module above to match the right field names.

Now that we have an Actions Dashboard for our custom section, we’ll need to make sure our page is using that one, instead of the generic SectionActionsDashboard. Just like in my previous article on adding the actions dashboard to a custom section, we’ll add that to the page, but using the name of ours for the “schemaName”. Other than that it will be the same. We’ll add the following to the modules section of the code (if your page doesn’t have a “modules” section, just add one):

"modules" {
    "ActionsDashboardModule": {
        "config": {
            "isSchemaConfigInitialized": true,
            "schemaName": "UsrMyCustomSectionDashboard",
            "useHistoryState": false,
            "parameters": {
                "viewModelConfig": {
                    "entitySchemaName": "UsrMySection",
                    "dashboardConfig": {
                        "Activity": {
                            "masterColumnName": "Id",
                            "referenceColumnName": "UsrMySection"
                        }
                    }
                }
            }
        }
    }
}

Note, the “schemaName” in the code above references our custom actions dashboard. This will load ours, which includes the code to get the contact and email address to use, instead of the SectionActionsDashboard. Now, the email address will default just as expected.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!