2

I have a local html page which contains javascript code that uses client context. I can run the code in sharepoint environment but i want to run it in my local html page, which is restricted due to authentication problem. How can I pass the authentication using jsom like we did it in csom using sharepointonlinecredential class.

my code look like this

var ctx = new SP.ClientContext("https://tenant.com");
var curWeb = ctx.get_web();     
var myList = curWeb.get_lists().getByTitle('newlist');
ctx.load(myList);
ctx.executeQueryAsync(
    function(){ 

        var fields = myList.get_fields()
        fields.addFieldAsXml('<Field ID="{c10f042e-ab13-435c-ab93-9885f0d48d02}" Name="myInternalName" DisplayName="A Multi User Column" Group="GroupName" Type="UserMulti" Mult="TRUE"></Field>', true, SP.AddFieldOptions.addToDefaultContentType)
        ctx.executeQueryAsync(
            function (){ alert('Created field!'); },
            function (){ alert('Error: ' + args.get_message()); } 
        );
    }, 
    function(sender, args){ alert('Error: ' + args.get_message()); }
);

plzz tell me how to add authentication

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.