I am trying to write a customer workflow to update two custom fields on salesorderdetail and I'm getting an error message can anyone help and suggest how to correct the code.
'product' entity doesn't contain attribute with Name = 'new_SupplierPO' and NameMapping = 'Logical'.
The custom fields definitely exist in salesorderdetail.
public class updateorderline : CodeActivity
{
[Input("Supplier Purchase Order")]
[RequiredArgument]
[ReferenceTarget("new_supplierpo")]
public InArgument<EntityReference> POfromorder { get; set; }
[Input("Order Line")]
[RequiredArgument]
[ReferenceTarget("salesorderdetail")]
public InArgument<EntityReference> salesorderdet { get; set; }
protected override void Execute(CodeActivityContext context)
{
IWorkflowContext workflowcontext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowcontext.InitiatingUserId);
var prodid = salesorderdet.Get<EntityReference>(context).Id;
if (prodid != null)
{
//update regarding product
Entity product = new Entity("product");
product.Id = prodid;
product["new_SupplierPO"] = POfromorder.Get<EntityReference>(context);
product["new_AddtoPO"] = false;
service.Update(product);
}
}
}
}