0

I am attaching documents to notes on order form.

the requirement is as soon as a file is attached its name should be updated by the order number

For example, if file name is latestOrders.csv and the order number is ABC-123-XYZ then after attaching the file name should be saved as

   ABC-123-XYZ - latestOrders.csv

is there any mean to accomplish?

Johan
  • 74,508
  • 24
  • 191
  • 319
AQ Dev
  • 43
  • 3
  • 14

1 Answers1

1

You can write a pre-create plug-in on annotation to handle this requirement. Identify if the annotation being created is 1) an attachment and 2) is related to an order. If both are true then modify the filename property. Here is a super quick code sample of the logic.

if (entity.LogicalName == "annotation" && entity.GetAttributeValue<bool>("isdocument") == true && entity.GetAttributeValue<string>("objecttypecode") == "salesorder")
{
    //I'm assuming you'll write a method to get the order number/name
    var newFilename = GetEntityName(entity.Attributes["objectid"] as EntityReference, entity.Attributes["filename"] as string);
    entity.Attributes["filename"] = newFilename;
}
Nicknow
  • 7,154
  • 3
  • 22
  • 38