Saturday, January 9, 2016

How to get and update people picker user id and Properties using SPServices?


function fnok()
{
try{
//username here
var uadd=$('div[id="ppladdtional"]').find('span>span>span').text();
var k=null;var puser=null;
if(uadd!=null||uadd!="")
{
//get User id  here
var klm=$("div[title='HAdd']").find("span>span").attr('sid');
$().SPServices({
    operation: "GetUserInfo",
    async: false,
    userLoginName: klm,
    completefunc: function (xData, Status) {
        $(xData.responseXML).find("User").each(function() {
            //alert($(this).attr("ID"));
            puser=$(this).attr("ID")+";#"+uadd;
            });
            }
            });
            k="HAdd";
}
else
{  k="flag";
}
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "Tracker",
ID:selectid,
 batchCmd: "Update",
 valuepairs: [["WFStart","1"],["HRecipients",user],[k,puser]],
completefunc: function (xData, Status) {

}
});
}
catch(e)
{alert(e);}
}

No comments:

Post a Comment