Forum Discussion

AthabascanDave's avatar
AthabascanDave
Copper Contributor
Apr 29, 2022
Solved

Auto-populate SharePoint columns with profile information

This has been asked previously but some of the information seems stale due to O365 changes, or just hasn't worked for me. 

 

The short version is I have a SharePoint list with the person or group column. When I add a person, I need a blank column to call that person's Department or whatever other information I need from their profile. 

 

Ideally, I'd just do it from account name. So if John Doe's account name is johnd, I enter johnd and blank columns for name, department, and whatever else are auto-populated. 

 

I understand this likely requires use of power automate, and I've played around with it but my skills are rudimentary and I have not found a template that seems to do this for me. Thanks in advance. 

  • AthabascanDave don't rely on templates, you can build a very simple flow from blank to do this. The overall flow looks like this and we'll look at the trigger and each of the 2 actions later:

     

    In the SharePoint list there is a person column called Employee and the Title column where the employee's name or account name can be stored. I've also added single line of text columns for position, department and mobile phone number. Those last 3 are what will be auto-populated.

     

    For the SharePoint form you can remove those 3 columns as you won't be entering that data manually. This will leave just the person column and the title column:

     

     

    So a new item is created, the flow will run and the 3 other columns will be populated with the employee's info:

    The flow has a SharePoint trigger of "When an item is created" and you select the site and the list:

     

     

    Next, add an Office 365 Users "Get user profile (v2)" action and for the User (UPN) field, click in the field and select Employee Email from the dynamic content box that appears:

     

     

    Finally, add a SharePoint "Update item" action. Again, select your site and list and in the ID field select ID from the when an item is created section of the dynamic content box. 

     

     

    Scroll down through the dynamic contents box and you'll see the employee's information is available to be selected from the Get user profile (v2) section of the dynamic content box:

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User

  • RobElliott's avatar
    RobElliott
    Silver Contributor

    AthabascanDave don't rely on templates, you can build a very simple flow from blank to do this. The overall flow looks like this and we'll look at the trigger and each of the 2 actions later:

     

    In the SharePoint list there is a person column called Employee and the Title column where the employee's name or account name can be stored. I've also added single line of text columns for position, department and mobile phone number. Those last 3 are what will be auto-populated.

     

    For the SharePoint form you can remove those 3 columns as you won't be entering that data manually. This will leave just the person column and the title column:

     

     

    So a new item is created, the flow will run and the 3 other columns will be populated with the employee's info:

    The flow has a SharePoint trigger of "When an item is created" and you select the site and the list:

     

     

    Next, add an Office 365 Users "Get user profile (v2)" action and for the User (UPN) field, click in the field and select Employee Email from the dynamic content box that appears:

     

     

    Finally, add a SharePoint "Update item" action. Again, select your site and list and in the ID field select ID from the when an item is created section of the dynamic content box. 

     

     

    Scroll down through the dynamic contents box and you'll see the employee's information is available to be selected from the Get user profile (v2) section of the dynamic content box:

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User

    • ulmoshare's avatar
      ulmoshare
      Brass Contributor
      Thanks Rob for this solution. I have one more question. If I use the module "when an item is created or modified" instead of "when an item is created", then I run in a loop. How can I tell the flow to only run once for the selected record in the list? If I add a trigger
      @equals(triggerBody()?['MA'],'')
      then it doesn't work either. Is there a solution for my question with Power Automate? Or does the solution only work new records?
    • JMMcD's avatar
      JMMcD
      Copper Contributor

      RobElliott 

       

      Preface that I am not an experienced user in Power Automate. I tried to follow your steps, but ran into an error.

       

      The specified user Office of the Exec Vice Chancellor UNL could not be found.
      clientRequestId: 96d61e56-3482-4c55-8fe3-5c5ab9dc327a
      serviceRequestId: 96d61e56-3482-4c55-8fe3-5c5ab9dc327a

       

      It pulled the correct department as "Office of the Exec Vice Chancellor UNL" is the right department for that user, but I received that error and the flow failed. My employee column is called Person.  It is a person column. I want the user to input a name in the person column, then PA to update other profile information (like department).

       

      Thank you!

       

       

       

    • AthabascanDave's avatar
      AthabascanDave
      Copper Contributor

      RobElliott 

       

      User not found error. Clearly I am calling the department successfully (cloud business office) but the flow throws the error and stalls out before updating the list. I've tried adding intermediary stages or blowing out/rebuilding the list but haven't had any luck.

       

      Here's my flow:

       

      Here's the error:

       

       

      Full error text from the body:

       

      {
        "error": {
          "code""ResourceNotFound",
          "message""User not found",
          "innerError": {
            "date""2022-05-02T16:59:32",
            "request-id""7a31d902-be64-43ec-9d2c-52b65fc9f25f",
            "client-request-id""7a31d902-be64-43ec-9d2c-52b65fc9f25f"
          }
        }
      }
       

       

      • RobElliott's avatar
        RobElliott
        Silver Contributor

        AthabascanDave your get user profile UPN looks wrong to me as it seems to be looking for a department not a user. Look at what I had in my example.

         

        Rob
        Los Gallardos
        Microsoft Power Automate Community Super User

Resources