Introduction:In today's digital landscape, managing costs efficiently is paramount for businesses utilizing Salesforce Marketing Cloud. One effective strategy involves optimizing user licenses, ensuring resources are used judiciously without compromising operational effectiveness.
Why Optimize Licenses?Effective license management not only reduces unnecessary expenditures but also streamlines operations, ensuring that resources are allocated where they are most impactful. This article explores a method using Server-Side JavaScript (SSJS) to identify and manage inactive users within Salesforce Marketing Cloud.
Using SSJS to Identify Inactive Users:Server-Side JavaScript (SSJS) provides a powerful way to automate tasks within Salesforce Marketing Cloud. Below is a script example that identifies users who haven’t logged in for over 3 months, helping administrators make informed decisions about license allocation:
Conclusion:Implementing SSJS for license optimization in Salesforce Marketing Cloud not only enhances cost-effectiveness but also supports efficient resource allocation. By leveraging these techniques, businesses can ensure they are maximizing the value of their Salesforce investment while maintaining operational agility.
Call to Action:Ready to optimize your Salesforce Marketing Cloud costs? Contact us today to learn more about how SSJS can help streamline your operations and improve ROI.
Platform.Load("core", "1");: Loads necessary libraries for Server-Side JavaScript in Salesforce Marketing Cloud.
prox.retrieve("AccountUser", cols, filter);: Retrieves user data based on specified columns and filters.
Filtered Results: Outputs a list of users who haven’t logged in for over 3 months, aiding in license management.
Approch 2
======================================
<script runat="server">
Platform.Load("core", "1");
try {
var api = new Script.Util.WSProxy();
api.setClientId({ "ID": 514012455 });
// Define columns to retrieve
var cols = ["AccountUserID", "ActiveFlag", "Email", "ID", "LastSuccessfulLogin", "Name", "UserID", "DefaultBusinessUnit"];
// Filter to exclude records with null or empty email addresses
var filter = {
Property: "Email",
SimpleOperator: "isNotNull",
Value: " "
};
// Retrieve AccountUser data
var retrieveResultAccountUser = api.retrieve("AccountUser", cols, filter);
var currentDate = new Date();
// Initialize HTML table for display
var displayTable = '<table width="600" border="1" align="center">' +
'<tr>' +
'<th>AccountUserID</th>' +
'<th>Email</th>' +
'<th>Name</th>' +
'<th>ActiveFlag</th>' +
'<th>BusinessUnit</th>' +
'<th>LastLogin</th>' +
'<th>DefaultBusinessUnit</th>' +
'</tr>';
var totalResults = retrieveResultAccountUser.Results.length;
// Process each retrieved result
if (totalResults > 0) {
for (var i = 0; i < totalResults; i++) {
var accountUser = retrieveResultAccountUser.Results[i];
var AccountUserID = accountUser["AccountUserID"] || "";
var Email = accountUser["Email"] || "";
var Name = accountUser["Name"] || "";
var ActiveFlag = accountUser["ActiveFlag"] ? "True" : "False";
var BusinessUnit = accountUser["Client"] ? accountUser["Client"]["ID"] : "";
var LastLogin = accountUser["LastSuccessfulLogin"] || "";
var DefaultBusinessUnit = accountUser["DefaultBusinessUnit"] || "";
// Calculate the difference in months
var lastLoginDate = new Date(LastLogin);
var monthsDifference = (currentDate.getFullYear() - lastLoginDate.getFullYear()) * 12 +
currentDate.getMonth() - lastLoginDate.getMonth();
// Check if the user has not logged in for the last 2 months
if (Email !== "" && ActiveFlag === "True" && monthsDifference > 2) {
displayTable += '<tr>' +
'<td>' + AccountUserID + '</td>' +
'<td>' + Email + '</td>' +
'<td>' + Name + '</td>' +
'<td>' + ActiveFlag + '</td>' +
'<td>' + BusinessUnit + '</td>' +
'<td>' + LastLogin + '</td>' +
'<td>' + DefaultBusinessUnit + '</td>' +
'</tr>';
}
}
}
displayTable += '</table>';
Platform.Response.Write(displayTable);
} catch (e) {
Platform.Response.Write("An error occurred: " + Stringify(e));
}
</script>