Skip to main content

I am trying to allow mass completion of tasks and the creation of a follow-up tasks for each lead/contact in a single popup.


Desired behaviour:


  1. User selects tasks for mass-completion and follow-up

  2. User hits mass action button

  3. Pop-up appears allowing user to update a field on the existing task and also create a new task for each selected record

Where I'm at:
  1. Pop-up works to auto-mass-complete existing tasks and display the fields I want for new task creation

Where I’m stuck:


I just can’t seem to manage the new task creation and context correctly. Either I’m able to create a new task, but I get a list of all contacts/leads instead of only those I want to create a new task for, or else I only seem to display existing tasks for those leads.


The code I’m using is below. I have a suspicion I need to either be using the context argument when calling my popup or else model.createRow, but it’d be great to get some guidance either way.


Thanks!


var $ = skuid.$,action = arguments 0].action,
list = arguments 0].list,
$xml = skuid.utils.makeXMLDoc,
model = arguments 0].model;
var NewTaskModel = skuid.model.getModel('NewTask');
var TasksModel = skuid.model.getModel('Tasks');
var selectedItems = list.getSelectedItems();
var rowsToUpdate = {};
var selectedTasks = e];
var listOfInfo = t];
arrayOfTaskInfo = a];
listOfWhoIds = f];
$.each( selectedItems,
function( i, item )
{
var row = item.row;
rowsToUpdatew row.Id ] = { Status: 'Completed' };
selectedTasks.push(row.Id);
listOfInfo.push("<value>" + row.Id + "</value>");
listOfWhoIds.push(row.WhoId);

arrayOfTaskInfo.push({
WhoId: row.WhoId,
OwnerId: row.OwnerId,
Type: "To-Do",
Status: "Not Started",
Subject: "",
ToDoDate: "",
Notes: ""
});
});

listOfInfo = listOfInfo.join('');
listOfWhoIds = listOfWhoIds.join('');
console.log(arrayOfTaskInfo);
model.updateRows(rowsToUpdate);
var popupXMLString = '<popup width="90%" title="Create follow-ups">'
popupXMLString += '<components>'
popupXMLString += '<pagetitle model="Tasks">'
popupXMLString += '<maintitle>Create follow-ups</maintitle>'
popupXMLString += '<actions>'
popupXMLString += '<action type="custom" snippet="" label="Save and create follow-ups" icon="ui-silk-accept"/>'
popupXMLString += '</actions>'
popupXMLString +='</pagetitle>'
popupXMLString += '<panelset type="standard" uniqueid="sk-3AZ3Uv-475" scroll="">'
popupXMLString += '<panels>'
popupXMLString += '<panel type="left" width="300px">'
popupXMLString += '<components>'
popupXMLString += '<basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="Tasks" buttonposition="" uniqueid="sk-3AZDsA-519" mode="read">'
popupXMLString += '<columns>'
popupXMLString += '<column width="100%">'
popupXMLString += '<sections>'
popupXMLString += '<section title="{{Subject}} - {{WhoId}}">'
popupXMLString += '<fields>'
popupXMLString += '<field id="Description" required="false"/>'
popupXMLString += '</fields>'
popupXMLString += '<renderconditions logictype="and">'
popupXMLString += '<rendercondition type="multiple" operator="in" fieldmodel="Tasks" sourcetype="fieldvalue" nosourcerowbehavior="skipandnorender" field="Id" value="" enclosevalueinquotes="false">'
popupXMLString += '<values>'
popupXMLString += listOfInfo
popupXMLString += '</values>'
popupXMLString += '</rendercondition>'
popupXMLString += '</renderconditions>'
popupXMLString += '</section>'
popupXMLString += '</sections>'
popupXMLString += '</column>'
popupXMLString += '</columns>'
popupXMLString += '</basicfieldeditor>'
popupXMLString += '</components>'
popupXMLString += '</panel>'
popupXMLString += '<panel>'
popupXMLString += '<components>'
popupXMLString += '<basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="Tasks" buttonposition="" uniqueid="sk-3AZF96-543" mode="read">'
popupXMLString += '<columns>'
popupXMLString += '<column width="50%">'
popupXMLString += '<sections>'
popupXMLString += '<section>'
popupXMLString += '<fields>'
popupXMLString += '<field id="WhoId" required="false"/>'
popupXMLString += '</fields>'
popupXMLString += '<renderconditions logictype="and">'
popupXMLString += '<rendercondition type="multiple" operator="in" fieldmodel="Tasks" sourcetype="fieldvalue" nosourcerowbehavior="skipandnorender" field="Id" value="" enclosevalueinquotes="false">'
popupXMLString += '<values>'
popupXMLString += listOfInfo
popupXMLString += '</values>'
popupXMLString += '</rendercondition>'
popupXMLString += '</renderconditions>'
popupXMLString += '</section>'
popupXMLString += '</sections>'
popupXMLString += '</column>'
popupXMLString += '<column width="50%">'
popupXMLString += '<sections>'
popupXMLString += '<section>'
popupXMLString += '<fields>'
popupXMLString += '<field id="Status" required="false" value="Not Started"/>'
popupXMLString += '<field id="Type" required="false" value="To-Do"/>'
popupXMLString += '</fields>'
popupXMLString += '<renderconditions logictype="and">'
popupXMLString += '<rendercondition type="multiple" operator="in" fieldmodel="Tasks" sourcetype="fieldvalue" nosourcerowbehavior="skipandnorender" field="Id" value="" enclosevalueinquotes="false">'
popupXMLString += '<values>'
popupXMLString += listOfInfo
popupXMLString += '</values>'
popupXMLString += '</rendercondition>'
popupXMLString += '</renderconditions>'
popupXMLString += '</section>'
popupXMLString += '</sections>'
popupXMLString += '</column>'
popupXMLString += '</columns>'
popupXMLString += '</basicfieldeditor>'
popupXMLString += '</components>'
popupXMLString += '</panel>'
popupXMLString += '</panels>'
popupXMLString += '</panelset>'
popupXMLString += '</components>'
popupXMLString += '</popup>';
var popupXML = $xml(popupXMLString);
// Launch the popup
var popup = skuid.utils.createPopupFromPopupXML(popupXML);
console.log(listOfWhoIds);

In the end, I didn’t figure out how to do this entirely in Javascript but have got pretty far using a combination of inline snippets and the WYSIWYG editor. 

Here’s what I did:

  • Implemented a standard “mass follow-up creation” mass action on a table, which creates the same number of new records are as selected in the table in a “TempTasks” model, populates a custom field with a specific value and opens a popup

  • Set the TempTasks model to only display records which have the custom field with the specific value

  • Added a table to the popup which display this subset of records

  • Added a mass action to create follow-ups for each record

  • Wipe out the custom value upon save

Hacky, but it works!


I’d say it looks beautiful…  Glad you got things worked out! 


Reply