{
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "!!!headerText!!!",
"wrap": true,
"size": "Large",
"weight": "Bolder",
"id": "card-title"
},
{
"type": "TextBlock",
"text": "!!!descriptionText!!!",
"wrap": true,
"id": "card-description",
"spacing": "Small"
},
{
"type": "Container",
"style": "emphasis",
"separator": true,
"spacing": "Medium",
"items": [
{
"type": "TextBlock",
"text": "!!!accountName!!!",
"wrap": true,
"weight": "Bolder",
"size": "Medium",
"id": "account-name"
},
{
"type": "TextBlock",
"text": "Account",
"wrap": true,
"isSubtle": true,
"spacing": "None"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Approved Pass Total",
"wrap": true,
"size": "Small",
"isSubtle": true
},
{
"type": "TextBlock",
"text": "!!!approvedPassTotal!!!",
"wrap": true,
"spacing": "None",
"id": "account-approved-pass-total",
"weight": "Bolder"
}
],
"verticalContentAlignment": "Bottom"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Total Passes Allowed",
"wrap": true,
"isSubtle": true,
"size": "Small"
},
{
"type": "TextBlock",
"text": "!!!totalPassesAllowed!!!",
"wrap": true,
"spacing": "None",
"id": "account-allowed-pass-total",
"weight": "Bolder"
}
],
"verticalContentAlignment": "Bottom"
}
]
},
{
"type": "Container",
"spacing": "Medium",
"separator": true,
"items": [
{
"type": "Container",
"targetWidth": "VeryNarrow",
"items": [
{
"type": "FactSet",
"facts": [
{ "title": "Account Number", "value": "!!!accountNumber!!!" },
{ "title": "Total ACV Number", "value": "!!!totalACV!!!" },
{ "title": "Open Pipeline", "value": "!!!openPipeline!!!" },
{ "title": "Marquee Account", "value": "!!!marqueeAccount!!!" }
]
}
]
},
{
"type": "Container",
"targetWidth": "Narrow",
"items": [
{
"type": "Container",
"items": [
{ "type": "TextBlock", "text": "Account Number", "isSubtle": true, "spacing": "Small" },
{ "type": "TextBlock", "text": "!!!accountNumber!!!", "weight": "Bolder", "spacing": "None" },
{ "type": "TextBlock", "text": "Total ACV Number", "isSubtle": true, "spacing": "Medium" },
{ "type": "TextBlock", "text": "!!!totalACV!!!", "weight": "Bolder", "spacing": "None" },
{ "type": "TextBlock", "text": "Open Pipeline", "isSubtle": true, "spacing": "Medium" },
{ "type": "TextBlock", "text": "!!!openPipeline!!!", "weight": "Bolder", "spacing": "None" },
{ "type": "TextBlock", "text": "Marquee Account", "isSubtle": true, "spacing": "Medium" },
{ "type": "TextBlock", "text": "!!!marqueeAccount!!!", "weight": "Bolder", "spacing": "None" }
]
}
]
},
{
"type": "Container",
"targetWidth": "Standard",
"items": [
{
"type": "ColumnSet",
"spacing": "Small",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Account Number", "isSubtle": true, "wrap": true },
{ "type": "TextBlock", "text": "!!!accountNumber!!!", "wrap": true }
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Total ACV Number", "isSubtle": true, "wrap": true },
{ "type": "TextBlock", "text": "!!!totalACV!!!", "wrap": true }
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Open Pipeline", "isSubtle": true, "wrap": true },
{ "type": "TextBlock", "text": "!!!openPipeline!!!", "wrap": true }
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Marquee Account", "isSubtle": true, "wrap": true },
{ "type": "TextBlock", "text": "!!!marqueeAccount!!!", "wrap": true }
]
}
]
}
]
},
{
"type": "Container",
"targetWidth": "Wide",
"items": [
{
"type": "ColumnSet",
"spacing": "Small",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Account Number", "isSubtle": true },
{ "type": "TextBlock", "text": "!!!accountNumber!!!" }
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Total ACV Number", "isSubtle": true },
{ "type": "TextBlock", "text": "!!!totalACV!!!" }
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Open Pipeline", "isSubtle": true },
{ "type": "TextBlock", "text": "!!!openPipeline!!!" }
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{ "type": "TextBlock", "text": "Marquee Account", "isSubtle": true },
{ "type": "TextBlock", "text": "!!!marqueeAccount!!!" }
]
}
]
}
]
}
]
}
]
},
{
"type": "TextBlock",
"text": "Recommended Contacts",
"weight": "Bolder",
"size": "Large",
"spacing": "Medium"
},
{
"type": "Container",
"items": !!!rows!!!
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Confirm selected contacts",
"id": "contact",
"style": "positive",
"data": {
"payload": { "_start_conversation": true },
"action_name": "contact",
"action_identifier": "1df8001993eb261058c03f8efaba10ca_contact"
}
}
]
}
let me provide row variable
_buildContactRows: function(repSysId, eventID, passTypeID, accountID) {
// --- (Your existing GlideRecord and variable setup) ---
var repEmail = "";
// ... (rest of the setup logic remains unchanged) ...
var userGr = new GlideRecord("sys_user");
if (userGr.get(repSysId)) {
repEmail = userGr.getValue("email");
}
var displayLimit = 0;
var grPass = new GlideRecord("u_reg_code_passes");
if (grPass.get(passTypeID)) {
displayLimit = parseInt(grPass.getValue("u_contact_recommendation_display_count"), 10) || 0;
}
var gr = new GlideRecord("u_reg_code_recommendation");
gr.addQuery("u_account_sales_rep_email", repEmail);
gr.addQuery("u_account", accountID);
gr.addQuery("u_recommended_nomination_program", passTypeID);
gr.addQuery("u_recommended_event", eventID);
gr.addQuery("u_nominated", false);
gr.setLimit(displayLimit);
gr.orderBy("u_contact_engagement_score");
gr.query();
var rows = [];
var contacts = [];
var itr = 0;
while (gr.next()) {
itr = itr + 1;
var contactSysId = gr.getValue("u_contact") || "";
var contactName = "";
if (contactSysId) {
var contactGR = new GlideRecord("sales_contact");
if (contactGR.get(contactSysId)) {
contactName = contactGR.getValue("name");
}
}
var jobTitle = gr.getValue("u_contact_job_title");
var justification = gr.getValue("u_justification_gen_ai_summary");
var toggleId = "contact_" +
itr + "|" +
contactName + "|" +
justification + "|" +
passTypeID + "|" +
contactSysId + "|" +
eventID + "|" +
accountID;
contacts.push({
name: contactName,
title: jobTitle,
toggleId: toggleId
});
}
// --- REUSABLE CONTACT BLOCK FUNCTION ---
// This function builds the single, stable contact card structure (1-up vertical details)
var buildContactBlock = function(contact) {
if (!contact) return null;
var inputToggle = {
"type": "Input.Toggle", // Use Input.Toggle for checkbox/switch
"title": "",
"value": "false",
"id": contact.toggleId,
"valueOn": "true",
"valueOff": "false",
"data": { /* Use your actual data here */ }
};
return {
"type": "Container",
"showBorder": true,
"roundedCorners": true,
"style": "emphasis",
"items": [
// Row 1: Name/Title/Toggle
{
"type": "ColumnSet",
"columns": [{
"type": "Column",
"width": "auto",
"items": [{ "type": "Icon", "name": "Person", "size": "Small" }]
},
{
"type": "Column",
"width": "stretch",
"items": [{
"type": "TextBlock",
"text": contact.name,
"weight": "Bolder",
"wrap": true
},
{ "type": "TextBlock", "text": contact.title || "", "wrap": true, "spacing": "None", "isSubtle": true }
]
},
{
"type": "Column",
"width": "auto",
"horizontalAlignment": "Right",
"items": [{
// Use Input.Toggle wrapped in a Column to achieve the desired alignment
"type": "Container",
"verticalContentAlignment": "Center",
"items": [inputToggle]
}]
}
]
},
// Row 2: Executive Contact (Vertical Stacked Detail)
{
"type": "ColumnSet",
"spacing": "Small",
"separator": true,
"columns": [{
"type": "Column",
"width": "auto",
"items": [{ "type": "Icon", "name": "Briefcase", "size": "xSmall" }]
},
{ "type": "Column", "width": "stretch", "items": [{ "type": "TextBlock", "text": "Executive Contact", "size": "Small", "spacing": "None" }] }
]
},
// Row 3: High Engagement (Vertical Stacked Detail)
{
"type": "ColumnSet",
"spacing": "ExtraSmall",
"columns": [{
"type": "Column",
"width": "auto",
"items": [{ "type": "Icon", "name": "CalendarArrowCounterclockwise", "size": "xSmall" }]
},
{ "type": "Column", "width": "stretch", "items": [{ "type": "TextBlock", "text": "High Engagement", "size": "Small", "spacing": "None" }] }
]
}
]
};
};
// --- 1. MOBILE LAYOUT (atMost:Narrow) - VERTICAL STACK (1-UP) ---
for (var i = 0; i < contacts.length; i++) {
var contact = contacts[i];
rows.push({
"type": "Container",
"targetWidth": "atMost:Narrow", // Only visible on mobile/narrow screens
"spacing": "Medium",
"items": [buildContactBlock(contact)] // Pushes one card per row
});
}
// --- 2. DESKTOP/TABLET LAYOUT (atLeast:Standard) - SIDE-BY-SIDE (2-UP) ---
for (var i = 0; i < contacts.length; i += 2) {
var contact1 = contacts[i];
var contact2 = contacts[i + 1];
var columnSetItems = [];
// Column 1 (First Contact)
if (contact1) {
columnSetItems.push({
"type": "Column",
"width": "stretch",
"items": [buildContactBlock(contact1)] // Reuses the stable block
});
}
// Column 2 (Second Contact)
if (contact2) {
columnSetItems.push({
"type": "Column",
"width": "stretch",
"items": [buildContactBlock(contact2)] // Reuses the stable block
});
} else if (columnSetItems.length === 1) {
// Add an empty column if needed
columnSetItems.push({ "type": "Column", "width": "stretch", "items": [] });
}
// Push the side-by-side structure
if (columnSetItems.length > 0) {
rows.push({
"type": "ColumnSet", // Use ColumnSet to enforce 2-up alignment
"targetWidth": "atLeast:Standard", // Only visible on desktop/tablet
"spacing": "Medium",
"columns": columnSetItems
});
}
}
return rows;
}. script include function of servicenow includes contact row variable wit adaptive card code ... let me know any one has inputs on same on same