Question

I am new to Visual Studio Workflows, so please excuse my ignorance. I am having an issue setting the value of a People field. I have an Account Id coming from an InfoPath form. I need my workflow to take that value and insert/convert it to the value of the Person column.

Account Id

domain\username

Workflow Code

private void onWorkflowActivated(object sender, ExternalDataEventArgs e)
{            
    String acctId = (String)workflowProperties.Item["Account Id"];
    acctId = "-1;#" + acctId;//I've been told this is the format the Person column is expecting
    workflowProperties.Item["Stakeholders"] = acctId;

    var s = workflowProperties.Item["Stakeholders"];//This is just a test
}

The current result is that the Stakeholders field is null. I would like it to be a Person Object with the value provided by the Account Id column. Any help would be much appreciated.

Was it helpful?

Solution

You are setting a value but not updating the item, I'd expect a .Update() in there.

workflowProperties.Item["Stakeholders"] = acctId;
workflowProperties.Item.Update(); 

Also, this may be affecting you:

If your field "" is field on the Infopath form and you have chose that field to be available on the form library then one thing you should check is that while you are adding a column to be available in the form library there is a check box at the bottom of that screen. That checkbox reads

"Allow users to edit data in this field by using a datasheet or properties page"

By default this check box is not checked. Can you please try checking this checkbox on the fields you want to update from your workflow?

From https://social.technet.microsoft.com/Forums/en-US/61518c32-b6a8-45c8-9b8e-deba1acc677c/workflowpropertiesitemfield-value-?forum=sharepointcustomizationlegacy

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top