0
votes

I have a State Machine SharePoint 2010 Workflow. The task is created by content type. I wanted to add a lookup column in task list. I was able to successfully add values to other custom field into the task list but having problem when I try add values to the lookup column of the task list.

Following code snippets were from CreateApproverTaskWithCT method.

//**I amable to add values to custom columns like this
createApproverTaskWithCT_TaskProperties1.ExtendedProperties[GetField("StatusReview")] = "Pending";

//**I am not able to add values to lookup column
createApproverTaskWithCT_TaskProperties1.ExtendedProperties[GetField("AgencyNameLookup")] = new SPFieldLookupValue(agencyItem.ID, agencyItem["Agency Legal Name"].ToString());

where agencyItem is a SPListItem for the corresponding lookup column. and GetField method return the guid of the custom field.

private Guid GetField(string field_name) { Guid statusFieldId = workflowProperties.TaskList.Fields.GetFieldByInternalName(field_name).Id; return statusFieldId; }

Any suggestions would be highly appreciated.

1

1 Answers

0
votes

I was able to insert values to look up field in task list by following method:

createApproverTaskWithCT_TaskProperties1.ExtendedProperties[GetField("AgencyNameLookup")] = String.Format(agencyItem.ID + ";#" + agencyItem["Agency Legal Name"].ToString());