Qntrl | Online Help | Business case 5: Transfer data to third-party applications (After create)

Business case 5: Transfer data to third-party applications (After create)

Today’s corporations use different software tools for different functions like inventory, payroll, utility, and so on. Server scripts allow organizations to fetch data from these third-party software or websites, and list the same in cards.
 

Business Scenario

Zylker uses Jira to track issues in their products. Sometimes, Zylker’s partners or clients might create a card in Qntrl to file a bug. To collate all issues in one place, Zylker wants to create an issue in Jira every time a card related to a bug is created in Qntrl.
 

Solution

We can create a specific orchestration to record issues and trigger a server script each time a new card is created in it.
  1. Create a new orchestration to record issues in product and save the issue link from Jira.
  2. Create a server script to file issues in Jira when cards are created in Qntrl's orchestration.
  3. Create a card and fill in the issue details to test the server script.
 

Sample Configuration

Step 1: Create an orchestration

Create a new orchestration titled 'Raise Issue' and add related custom fields to it.
  1. Add a link field--Issue Link--to record the issue link from Jira.

 
Once the form is saved, proceed to design the blueprint, set permissions, and publish the orchestration.
 

Step 2: Code server scripts

Now, proceed to code the server script to send details to Jira.
  1. Create a new server script and enter the name as 'File issue in Jira'.
  2. Choose Raise Issue in the  Form dropdown.
  3. Choose Job as the Execution Location to execute the script.
  4. Choose After Create  as the Execution Trigger to execute this script whenever the card page loads.
  5. Copy and paste the below script into your script editor and replace the parameter names.
    1. You can use the ? icon at the top-right corner of the script editor to refer to parameter names.
  6. Once the script is ready, Publish it. 

  1. function afterCreate(){
  2.     var globalVars = ZDK.Vars.getGlobalVariables();
  3.     var job = current.Job;
  4.  
  5.     var jiraAuthBase64 = ZDK.Crypto.base64Encode(globalVars["JiraEmail"] + ":" + globalVars["JiraApiKey"]);
  6.     var payload = getJiraPayload(job.getTitle(), job.getDescription(), globalVars["JiraProjectKey"]);
  7.  
  8.     var url = "https://" + globalVars["JiraDomain"] + "/rest/api/3/issue";
  9.     var headers = { 
  10.         'Authorization': "Basic "+jiraAuthBase64,
  11.         'Accept': 'application/json',
  12.         'Content-Type': 'application/json'
  13.     }
  14.     var resp = ZDK.HTTP.request(
  15.         url,
  16.         "post",
  17.         headers,
  18.         "",
  19.         payload,
  20.         ""
  21.     );
  22.     if (typeof resp == "string") {
  23.         resp = JSON.parse(resp);
  24.     }
  25.     console.log("Res = " + JSON.stringify(resp));
  26.     if (resp && resp.body) {
  27.         if (resp.status == 400) {
  28.             console.log("Jira issue creation failed, "+JSON.stringify(resp));
  29.         } else {
  30.             if (typeof resp.body == "string") {
  31.                 resp.body = JSON.parse(resp.body);
  32.             }
  33.             var id = resp.body.id;
  34.             var key = resp.body.key;
  35.             var link = "https://" + globalVars["JiraDomain"] + "/browse/" + key;
  36.             job.setVariable("JiraId", id);
  37.             job.setVariable("JiraKey", key);
  38. //Select issue link parameter here
  39.             job.setValue(current.Layout.Fields.<select issue link parameter here>.id, link);
  40.             console.log("Jira issue created, id = " + id + ", key = " + key);
  41.         }
  42.     } else {
  43.     }
  44.  
  45. }
  46.  
  47.  
  48. function getJiraPayload(title, desc, project) {
  49.     if (!title) title = "";
  50.     if (!desc) desc = "";
  51.     var payload = {
  52.         "fields": {
  53.             "summary": title,
  54.             "issuetype": {
  55.                 "id": "10004"
  56.             },
  57.             "project": {
  58.                 "key": project 
  59.             },
  60.             "description": {
  61.                 "type": "doc",
  62.                 "version": 1,
  63.                 "content": [
  64.                     {
  65.                         "type": "paragraph",
  66.                         "content": [
  67.                             {
  68.                                 "text": desc,
  69.                                 "type": "text"
  70.                             }
  71.                         ]
  72.                     }
  73.                 ]
  74.             }
  75.         }
  76.     };
  77.     return JSON.stringify(payload);
  78. }



Step 3: Add card

When the orchestration and server script are ready, we can test the script by creating a new card.
  1. Navigate to Cards and click Add Card.
  2. Select Raise Issue  from the Form dropdown.
  3. Enter the bug details.
  4. Save the card.

 
Check if an issue with the same details has been created in your Jira account.


      

    Zoho DataPrep Personalized Demo

    If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

    Zoho CRM Training

      Create, share, and deliver

      beautiful slides from anywhere.

      Get Started Now





              Zoho CRM Training Programs

              Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

              Zoho CRM Training

                  Zoho SalesIQ Resources



                      Zoho TeamInbox Resources




                                Zoho DataPrep Resources

                                  Zoho DataPrep Demo

                                  Get a personalized demo or POC

                                  REGISTER NOW


                                    Design. Discuss. Deliver.

                                    Create visually engaging stories with Zoho Show.

                                    Get Started Now











                                                          Resources

                                                          Videos

                                                          Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                          eBooks

                                                          Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                          Webinars

                                                          Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                          CRM Tips

                                                          Make the most of Zoho CRM with these useful tips.



                                                            Zoho Show Resources