Scenario
In my previous article, Upload Document In Document Library And Save Document To Google Drive Using Nintex Workflow Office 365, I described how to upload files into the document library and save into Google drive.
Now, I have added one more column to the document library which will be used to delete that particular document from Google Drive. The requirement is that when the user updates the value to the field “Delete from Google Drive” to “Yes”, the corresponding file should be deleted from the document library.
Remember that all the files are uploaded in “Document Library” folder on Google Drive.
Approach
The following is my document library with added column “Delete from Google drive”.
Just click on "Library Setting >> Nintex Workflow".
It will open the Nintex Workflow Designer in your browser. "Click on New List Workflow".
Now, search in the Actions - “Set Workflow Variable” and drag and drop that action to the Workflow canvas.
Now, double click on the action or click on the down arrow and click "Configure".
It will open the configuration settings of the “Set Workflow Variable” action.
Create a variable of text type and name it. I have named “Delete File”. And, set the value from “Item Property” to “Delete from Google drive”.
Click on "Save".
Now, search in the Actions “Conditional Branch” and drag and drop that action to the Workflow canvas.
Now, double click on the action or click on the down arrow and click "Configure".
It will open up the configuration settings of the “Conditional Branch” action.
Here, we have to make sure that if the value of the field “Delete from google drive” is “Yes”, then in that case, only the file should be deleted. So, ensure that in “Conditional Branch”. Set the Value from Workflow variable “Delete File” and in the input section, enter “Yes”.
The final configuration is shown in the figure.
Click on "Save".
Now, search in the Actions "Google Drive delete file" and drag and drop that action to the “Yes” part of the “Conditional Branch” action in the Workflow canvas.
Now, double click on the action or click on the down arrow and click "Configure".
It will open up the configuration settings of the "Google Drive delete file".
Here are a few configurations required,
In “Identify file by”, select “File Name And Source Folder” because we know the filename and folder name.
In “File ID or name”, select the “Name (for use in forms)” property from Item Context as we are deleting current item.
Provide source folder name in “Source folder” input field. Here, in our case, it's “Document Library”.
In “Delete permanently”, select as per your requirement.
Navigate to "Authorize user" section. Here, you have to enter your Gmail account associated with your Google Drive. Also, make sure that you have currently access to the email account.
Click on "Save".
So, after configuring the form, your action will look similar to this.
Now, your workflow is completed. Just click on "Publish" and publish the Workflow.
Enter unique name for the Workflow and select "Start when items are updated" in "Start option" and Publish. (You can select any of the the start actions here).
Once the workflow is published then go the document library and update the property of the document. Here I have upload Test Document into document library. So I am updating the property of this document.
Important part of the Action
Now, once the workflow is fired, it will send an email to ask for the permission. So go to your inbox and check the mail. There would be a mail from Nintex which would ask the permission to access your associated google drive.
Here you have 2 options.
Provide Google Drive account credentials and authorize access
If you want to allow access then click on this link
Deny access to my Google Drive account
If you don’t know about the source of the workflow then simply click this and it will not be able to access the Google Drive
Now, when you click on "Provide Google Drive account credentials and authorize access" you will have following screen.
Just click on "Allow". And you will be redirected to Nintex save preferences of permission screen
Note that here you have 2 options,
Yes
If you click on Yes, your choice will be saved to Nintex and next time Nintex can access your Google Drive without sending you the email to ask the permission.
No
If you want to allow Nintex to access your Google Drive for this time only then simply click on "No"
And now, you will find that your file “Test Document.docx” will be deleted from the folder “Document Library” from Google Drive.
If you have any query regarding this please feel free to ask in the comment section.