Often you may want to limit the number of documents a user can submit in an App/Product (i.e. a contest app that limits one submission per user). You can accomplish this by creating an Integration to check whether any other documents have already been submitted by the same user in the given app. With this integration you can then trigger a Read-Only Text gadget to warn the user they've already submitted and also build in a workflow branch to address the document if they still proceed with submission. Below outlines the steps necessary to add this to your form.
Creating the Integration
First you'll need to create the integration in Kuali by utilizing GraphQL to get the query and variables necessary for the integration URL endpoint. Within GraphQL you'll want to put in the below query to search app documents by certain variables (App ID and User ID) to find a totalCount
of number of documents:
Within the Variables we're going to specifically set the appId
and userId
value but when we create the URL endpoint for the Kuali integration we'll set these appId and user values as an input in the integration.
AppID
and UserIDM
you can look at the URL for the given app or user profile. For example, in the Travel Approval app that we're utilizing in this query if you open the app and then look at the URL you'll see the AppID
:
Similarly in the user profile found in People if you look at the URL you'll see the UserID
in the URL at the end:
Once you've set the above you'll have the necessary information to run the query and you'll get the below results (21 total documents created by this user):
From here you can use the full query information and variable information to generate the URL necessary. Please notice, I replaced the specified App Id and User value with an input of {{AppID}}
and {{UserID}}
so those would be fillable inputs in the integration itself. So the final Integration URL we'll use in the Integration is the following:
https://jessicapeck.kualibuild.com/app/api/v0/graphql?query=query ( $appId: ID!
$skip: Int! $limit: Int! $sort: [String!] $query: String $fields: Operator )
{ app(id: $appId) { id name documentConnection( args: { skip: $skip limit: $limit
sort: $sort query: $query fields: $fields } keyBy: ID ) { totalCount } } }&variables={
"appId": "{{AppID}}", "skip": 0, "limit": 25, "sort": [ "meta.updatedAt" ], "query":
"", "fields": { "type": "AND", "operators": [ { "field": "meta.createdBy.id",
"type": "IS", "value": "{{UserID}}" } ] } }
So when creating the integration you'll complete as below - notice to get to the necessary output of total count we'll use data.app.documentConnection.totalCount
as the ID Key and Label Key and the Output Data Path. And additional API creation reference can be found in the Create an API Integration article.
Run a test and input the App ID and User ID to successfully fetch data and then save the integration.
Adding to your Form
Now that you have the integration created you can then add to your form to start utilizing. Add an Advanced Data Lookup (Single Item) gadget and point it at the newly created integration. Then you'll need to enter the necessary inputs for the integration to run. For the App ID you should use a Fixed value and input the id for the desired app. And for the User ID you can use the Created By metadata (make sure in the setting gear icon you chose the Value to use of 'ID'. And lastly you will want to mark it headless and also enable the Add linked auto-filled gadget options to show the Total Count output so it can be dragged over to the form.
Next you'll want to add a Read-Only Text gadget to display if this value is over 0 (indicating they've already submitted a document in the app). Notice we've enabled the Limit visibility based on other gadgets and put in the rule to check if the Total Count is greater than 0:
Now in the form the read-only warning text configured will display to the end user if they've already submitted a document in the app.
This won't prevent the user from submitting the document but you can also configure a workflow branch to trigger in this scenario to help do a special review of the document and take the necessary actions (i.e. disapprove or return to the user, etc). More information on added special logic in workflow is explained in the next section.
Utilizing in Workflow
If the Total Count of documents submitted by the user completing the form is greater than zero and they still submit you can create a special branch in the workflow to review and address. To do this we'll utilize the same Total Count output form field and put the same logic in a workflow Branch step (with an Approval stop within:
Comments
0 comments
Article is closed for comments.