I’m trying to add an extension field to a call to record the last Action an Officer typed on a call. I’m doing this as we want to display (on email alerts, for example) the last “real” action taken on a call and we don’t want to display the system generated text that is often saved in the SOLUTION_DESC column.
e.g. email sent displays like this:
I have successfully created the extension field and have got this updating when the call is Actioned (details of the changes I have made are below).
The problem I have is that the email that is sent to Officers receiving a forwarded call doesn’t have the latest version of the field data on it. It’s as if the system hasn’t written the data to the database before the “send email” logic runs. If I immediately query the record in SQL after deferring or forwarding the call I can see the update is writing to the extension field in the database, but it must be after the send email.
e.g. I edit a call and type something into the Actions & Solutions field. I forward the call to a group. The email that is sent to the groups officers has the extension field set to display on it, but it doesn’t display the latest Action typed in, it displays the previous Action (if there was one).
Any suggestions on how I make sure the email displays the latest Action?
Changes I’ve made so far:
In Custom_InCallDetails.js
Added custom function:
function setLastUserActionText() {
var da = document.all;
var sd = da.SOLUTION_DESC_HTML_EDITOR.AsText;
if ((da.TEMPLATE_IND.value != 1 ) && (sd != '') && !(TF(da.TakeOver.value)))
{
var DB = FindNavWindow().document.all.DB;
var localRS;
var OfficerName;
var CurrentDate = new Date();
DB.ClearParam();
DB.AddParam("REF", da.OFFICER_REF.value);
localRS = DB.GetRecordSet("Get Officer Name");
if (localRS == null || localRS.recordCount == 0)
OfficerName = "(Unknown)";
else
OfficerName = (localRS("FULL_NAME").value);
DB.ClearParam();
DB.AddParam("CALL_NUMBER", da.CALL_NUMBER.value);
DB.AddParam("SOLUTION_DESC", (sd + "\r\n(By " + OfficerName + " on " + CurrentDate.toLocaleString() + ")"));
localRS = DB.GetRecordSet("CustomGetLastUserActionText");
if (localRS == null || localRS.recordCount == 0)
{
localRS = DB.GetRecordSet("CustomAddLastUserActionText");
localRS = DB.GetRecordSet("CustomUpdateExtensionDataAllocation");
}
else
localRS = DB.GetRecordSet("CustomSetLastUserActionText");
}
}
Updated OnSubmit function to call it:
function OnSubmit(s)
{
…
p.Submitted = false;
return false;
}
// Start Customisation
setLastUserActionText();
// End Customisation
SetSubmitValues();
…
}
In infra_custom.sql
! CustomUpdateExtensionDataAllocation
CustomUpdateExtensionDataAllocation
UPDATE SU_NUMBER_ALLOC SET NUMBER_ALLOC = (SELECT MAX(REF)+1 FROM SU_EXTENSION_DATA) WHERE TABLE_ALLOC = 'SU_EXTENSION_DATA'
! CustomGetLastUserActionText
! 500219 is the Ref of the “Last User Action Text” field
CustomGetLastUserActionText
SELECT REF FROM SU_EXTENSION_DATA WHERE REF_NO = :nCALL_NUMBER AND EXTENSION_FIELD_REF = 500219
! CustomAddLastUserActionText
CustomAddLastUserActionText
INSERT INTO SU_EXTENSION_DATA
(REF,
REF_NO,
EXTENSION_FIELD_REF,
VALUE_STRING,
CORE_ENTITY)
SELECT
(SELECT MAX(REF)+1 FROM SU_EXTENSION_DATA) + ROW_NUMBER () OVER (ORDER BY :nCALL_NUMBER),
:nCALL_NUMBER,
500219,
:sSOLUTION_DESC,
1
! CustomSetLastUserActionText
CustomSetLastUserActionText
UPDATE SU_EXTENSION_DATA SET VALUE_STRING = :sSOLUTION_DESC WHERE REF_NO = :nCALL_NUMBER AND EXTENSION_FIELD_REF = 500219