Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

JSLink - EditForm: Unable to get property 'get_current' of undefined or null reference

$
0
0

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!



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>