ArdeviaForum

Execute Script Action - Calling REST Service and Populating Fields

Discussion created by ArdeviaForum on Aug 19, 2016
Latest reply on Aug 19, 2016 by ArdeviaForum

Original Post by PJamhour (Imported from Ardevia Forum)

I am currently calling a REST web service (on button click) to return data from the SharePoint User Profile Service. The call works fine and I am able to parse the JSON response.

 

However, I would like to extract some elements from the JSON response and set them as form field values. But attempting to set the values through the Execute Script action does not seem to be doing anything.

 

Here is the code that I am using in my Execute Script Action.

Code:

 

jQuery.ajax({
    type: "GET",
    contentType: "application/json; charset=utf-8",
    url: "https:///_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+[[Requestor.Email]]+"'",
    data: "",
    dataType:"json",
    success: function(resp){  
        alert(resp.UserProfileProperties[10].Value);
        [[]] = resp.UserProfileProperties[10].Value;    
    },  
    error: function(e){  
         alert(e.Message);  
    }  
}); 

 

 

 

The only thing that I can think of is setting the value of another field to this JSON response, and then using the set form field value action to process that data, per field I want to populate.

Outcomes