CRM 2011 Workflows: Finding Previous Values

Currently, I have a workflow that starts when a specific decimal field changes.

Is it possible to get the difference between old and new values ​​through a workflow?

+4
source share
1 answer

Finally, it was time to test this, and it’s quite possible to get preliminary values ​​in a workflow by assembling a workflow.

Here is what I did:

I created a workflow on contact with a trigger by LastName. The workflow contains a link to the name of the last field and its own assembly of the workflow . I opened a contact and changed its name from "Foo" to "Bar"

Custom Workflow Build Code:

protected override void Execute(CodeActivityContext context) { IWorkflowContext workflow = context.GetExtension<IWorkflowContext>(); Entity preImage = workflow.PreEntityImages.Values.FirstOrDefault(); string content = RetrievePreImageLastname(preImage); using (StreamWriter writer = new StreamWriter(@"C:\temp\log.txt", true)) { writer.WriteLine("writing workflow assembly"); writer.Write(content); } } public string RetrievePreImageLastname(Entity value) { if (value == null) return "PreImage is Empty"; return string.Format("lastname pre image value: {0}", value.GetAttributeValue<string>("lastname")); } 

And that was the result:

workflow assembly

last preview value: foo

We hope this helps anyone in the future.

+4
source

All Articles