Hi,
I have a JSLink New and Edit form, which worked perfectly until I installed the latest CU. The template has to load some data from another list via a CAML query, so I need a SharePoint context. The SharePoint context is not yet loaded due to the lazy loading.
I know I can do this via: SP.SOD.executeOrDelayUntilScriptLoaded(loadContext, 'sp.js');
But since this is a assynchronous call, my code doesn't wait for it. How should I implement this function for a JSLink field template?
My code looks like this:
(function () {
var mjhOverrides = {};
mjhOverrides.Templates = {};
mjhOverrides.Templates.Fields = {
'KGDCMeetingDate': {
'NewForm': dateFieldTemplate,
'EditForm': dateFieldTemplate
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(mjhOverrides);
})();
function dateFieldTemplate(ctx) {
var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx);
formCtx.registerGetValueCallback(formCtx.fieldName, function () {
//Returnvalue for the save function
return $("#" + formCtx.fieldName + "Select").val();
});
//Get context and call callendar
var clientContext = SP.ClientContext.get_current(); // ==> error on this line= > Unable to get property 'get_current' of undefined or null reference
var oList = clientContext.get_web().get_lists().getByTitle('Calendar');
//Query other list via caml query and build html select element
this.currentList = clientContext.get_web().get_lists().getById(_spPageContextInfo.pageListId);
//.... caml query, process list items,...
return this.ReturnHtmlValue;
}
Thanks in advance!