05-12-2023 10:22 AM
We have several workflows that for audit backup we have the users attach documents. With employee turnover the next person didn't know they had to attach the document. Is there something like an After Event rule you can do to check that something was attached or in a confirmation step?
Solved! Go to Solution.
05-12-2023 02:01 PM
Hi, a Confirmation Rule check is very easy to use for enforcement of business processes. Here is a code snippet we use in our courses, of how you could check for an attachment if an account has a non-zero amount, thereby requiring a supporting details attachment:
'Check an Account value and if it is greater than zero, request a file be attached
args.ConfirmationRuleArgs.DisplayValue = api.Data.GetDataCell("V#YTD:A#60999:F#None:O#Forms:I#None:U1#None:U2#Services:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None").cellAmount
If args.ConfirmationRuleArgs.DisplayValue = 0 Then
Return True
Else
'We failed the value test, check for a file
If api.Data.HasDataAttachmentsWithFile("V#Annotation:A#60999:F#None:O#Forms:I#None:U1#None:U2#Services:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None") Then
'We have a file attached, so pass the rule
args.ConfirmationRuleArgs.Info1 = "File attachment found"
Return True
Else
'File not found, we fail
args.ConfirmationRuleArgs.Info1 = "File Attachment Missing. Navigate back to the Product Sales Form and add an attachment as an Annotation to the Services data cell."
Return False
End If
End If
You would attach that as the Rule Formula to a Confirmation Rule that might look like this:
02-14-2024 04:25 PM
05-12-2023 10:29 AM
You can definitely use the DataQualityEventHandler to look and make checks in between steps in a workflow. You should then be able to use GetDataAttachments as a Boolean event and determine if it should stop the workflow. Alternatively, if you're using Confirmation Rules, you should be able to utilize that in a similar way.
05-12-2023 10:45 AM
Thank you for the confirmation and information! I was thinking somewhere I'd seen you can before.
05-12-2023 02:01 PM
Hi, a Confirmation Rule check is very easy to use for enforcement of business processes. Here is a code snippet we use in our courses, of how you could check for an attachment if an account has a non-zero amount, thereby requiring a supporting details attachment:
'Check an Account value and if it is greater than zero, request a file be attached
args.ConfirmationRuleArgs.DisplayValue = api.Data.GetDataCell("V#YTD:A#60999:F#None:O#Forms:I#None:U1#None:U2#Services:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None").cellAmount
If args.ConfirmationRuleArgs.DisplayValue = 0 Then
Return True
Else
'We failed the value test, check for a file
If api.Data.HasDataAttachmentsWithFile("V#Annotation:A#60999:F#None:O#Forms:I#None:U1#None:U2#Services:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None") Then
'We have a file attached, so pass the rule
args.ConfirmationRuleArgs.Info1 = "File attachment found"
Return True
Else
'File not found, we fail
args.ConfirmationRuleArgs.Info1 = "File Attachment Missing. Navigate back to the Product Sales Form and add an attachment as an Annotation to the Services data cell."
Return False
End If
End If
You would attach that as the Rule Formula to a Confirmation Rule that might look like this:
05-12-2023 03:56 PM
This is the right answer. There is even a Snippet to do this sort of work.
09-26-2023 08:10 PM
Hello,
I see the solution listed above works for Forms. Is there something similar for Journals where workflow, account and all other dimensions are variable?
Thanks,
05-15-2023 11:33 AM
This is excellent and great for me to check the a file attachment to data which I can use, but is there also a way to check that a file was attached to the workflow step with the paperclip attachment at the top of the workflow step?
02-14-2024 04:25 PM
02-14-2024 05:45 PM
Hi @GParreiras
I think you meant to use objBRApiForms.RequiredForms in your example, but the concept is still the same -- and nice example by the way.
So, for those reading this there are three collections of forms that you can use with the XFFormsForWorkflow class -- RequiredForms, OptionalForms, and DeprecatedForms. Also note that there is a very useful property in this class, called AreAllRequiredFormsCompleted which returns a boolean True or False response.
02-15-2024 07:05 AM
Hi @KurtMayer , thanks for the additional information.
Yes, in this case, I'm looping through the OptionalForms to check if one of them has the attachment.
While we're here, let me add something. I'm using the UniqueID to check for attachments. It's important to note that the UniqueID is created on the fly as soon as any user clicks on the form. So, before that, if you try to use any function that requires the UniqueID on a form that hasn't been opened yet, the operation will return the 'Object reference not set to an instance of an object' error.
This would be the UniqueID before the form usage: '00000000-0000-0000-0000-000000000000', you can check for that to see if the UniqueID already exists
02-15-2024 09:43 AM
Thank you! I'll take a look at this, I really appreciate you taking time to give me a solution!