contentAdfStringified | {"version":1,"type":"doc","version":1,"content":[{"type":"table","contentattrs":[{"type":"tableRow"{"isNumberColumnEnabled":false,"layout":"default","localId":"43163384-94e0-4c47-8aef-8cf80fbea22d"},"content":[{"type":"tableHeadertableRow","attrscontent":[{"colspantype":1"tableHeader","rowspanattrs":1{},"content":[{"type":"paragraph","content":[{"texttype":"Add-on:text","typetext":"textAdd-on:"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"inlineExtension","attrs":{"extensionType":"com.atlassian.confluence.macro.core","extensionKey":"short-text","parameters":{"id":"3ljpa1bpat","extensionKey":"short-text","name":"content:space","placeholder":"","isRequired":false,"type":"line","atlassian-macro-output-type":"INLINE"}}}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"texttype":"Question:text","typetext":"textQuestion:"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"inlineExtension","attrs":{"extensionType":"com.atlassian.confluence.macro.core","extensionKey":"short-text","parameters":{"id":"yw0m5kzhsc","extensionKey":"short-text","name":"page:title","placeholder":"","isRequired":false,"type":"line","atlassian-macro-output-type":"INLINE"}}}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"texttype":"Answer:text","typetext":"textAnswer:"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"extension","attrs":{"extensionType":"com.atlassian.confluence.macro.core","extensionKey":"paragraph","parameters":{"id":"vankxmt0w5","extensionKey":"paragraph","name":"kbAnswer","isRequired":false,"Type":"area","atlassian-macro-output-type":"BLOCK"},"layout":"default"}}]}]}]}]} |
---|
fieldGroupName | migrated |
---|
fieldGroupId | fdvrbsdku0 |
---|
excerpt | Add-on: Classic Connector for Salesforce & Jira Question: Synchronizing from Salesforce using JIRA REST API Answer: To those who require multiple mappings to synchronize from Salesforce.com, we suggest following these steps: This setup is only valid for a one-to-one relationship between a JIRA Issue and a Salesforce.com Object Before you write Apex code that calls a remote URL, you have to allow Salesforce.com to make a call to an external server. Log in to Salesforce.com. Go to Your Name > Setup > Administration Setup > Security Controls > Remote Site Settings. Add new remote site. Enter the name of remote site. Enter your JIRA URL in Remote Site URL, e.g., http:// yourjiraurl .com Click Save. The JIRA Issue updates REST API requires a JIRA Issue Key or Id. JIRA_URL/rest/api/2/issue/{issueIdOrKey} Here are the steps to get a JIRA issue Key: Create a text custom field ( Setup > Customize > Cases > Fields ), e.g: JIRA_Key Add an outbound map from the key to the newly created text field (JIRA_Key) Once you are done, you can start writing the code. Here are the steps to write a Salesforce.com Apex Class with the following mapping from Salesforce.com to JIRA: Salesforce Fields Salesforce field type JIRA Fields JIRA field type Subject Text field Summary JIRA Issue Summary Assignee Picklist (custom filed) Assignee JIRA Issue Assignee Priority Picklist Priority JIRA Issue Priority Requested_By Picklist (custom filed) Requested_By(customfield_10400) Select List (single choice) Log in to Salesforce.com. Go to Setup > App Setup > Develop > Apex Classes > New Paste this code into the field: global class JIRAWebserviceCalloutSyncFields { @future (callout=true) WebService static void syncfields(String JIRA_Key) { //Modify these variables: String username = 'username'; String password = 'password'; String jiraURL = ' http://yourjiraurl.com'; sObject s = [SELECT Subject, Assignee__c, Priority, Requested_By__c FROM Case WHERE JIRA_Key__c = :JIRA_key LIMIT 1]; String c_summary = (String) s.get('Subject'); String c_assignee = (String) s.get('Assignee__c'); String c_priority = (String) s.get('Priority'); String c_requested_by = (String) s.get('Requested_By__c'); String priorityId; //Map Salesforce Prority to JIRA Prority if (c_priority == 'Blocker') { // Salesforce.com Priority priorityId = '1'; // JIRA Priority ID } else if (c_priority == 'Critical') { priorityId = '2'; } else if (c_priority == 'Major') { priorityId = '3'; } else if (c_priority == 'Minor') { priorityId = '4'; } else if (c_priority == 'Trivial') { priorityId = '5'; } //Construct HTTP request and response HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); //Construct Authorization and Content header Blob headerValue = Blob.valueOf(username+':'+password); String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); req.setHeader('Content-Type','application/json'); //Construct Endpoint String endpoint = jiraURL+'/rest/api/2/issue/'+JIRA_Key; //Set Method and Endpoint and Body req.setMethod('PUT'); req.setEndpoint(endpoint); req.setBody('{ \"fields\":{\"summary\": \"'+c_summary+'\", \"assigne\":{\"name\":\"'+c_assignee+'\"}, \"priority\":{\"id\":\"'+priorityId+'\"}, \"customfield_10400\":{\"value\":\"'+c_requested_by+'\"}}}'); try { //Send endpoint to JIRA res = http.send(req); } catch(System.CalloutException e) { System.debug('ERROR:' + e); System.debug(res.toString()); } } } Change the variables accordingly: Click Save . The Usage of Written Class Now that the class is ready to be used and it can be called in various ways including: From within a Trigger. From Sync Fields button. Trigger Salesforce.com Trigger can be used to automate the synchronization of JIRA issue. It is event-based process similar to JIRA workflow, yet more flexible. In this example, we want to automate JIRA issue creation when Case is created: VERY IMPORTANT NOTE: You may need to create a custom profile called "JIRA Agent" in Salesforce.com to avoid causing an infinite loop . Then assign a user to that profile and block it to execute the trigger. This way, any cases created from JIRA will not trigger creation of more issues back to JIRA. Make sure that this user is used in the Application Links authentication in JIRA. First, create a custom profile called " JIRA Agent ": Log in to Salesforce.com. Go to Setup > Administration Setup > Manage Users > Profiles > New Profile . Choose the " Existing Profile " to be: Custom: Support Profile. Fill in " Profile Name " with: JIRA Agent. Click Save. "CUSTOM: SUPPORT PROFILE" NOT AVAILABLE? Your version of Salesforce may not have the Custom: Support Profile option. If so, you can create a new profile or clone from any existing profile. But please make sure that the profile has Read , Edit and Create permissions for the relevant object. Second, assign the created profile to the specific user that will be used in the JIRA Connector: Go to Setup > Administration Setup > Manage Users > Users. Create/Edit the user that is used as JIRA agent. Use the created profile as the profile of the user. Click Save. Third, add the Trigger code to the Case Trigger. Write the Apex Class as described above Go to Setup > Application Setup > Customize > Cases > Triggers . Create New Trigger and replace the code with: trigger SyncFields on Case (after update) { //Identify profile name to be blocked from executing this trigger String JIRAAgentProfileName = 'JIRA Agent'; List<Profile> p = [SELECT Id FROM Profile WHERE Name=:JIRAAgentProfileName]; //Check if specified Profile Name exist or not if(!p.isEmpty()) { //Check if current user's profile is catergorized in the blocked profile if(UserInfo.getProfileId()!= String.valueOf(p[0].id)) { for (Case c : Trigger.new) { //Define parameters to be used in calling Apex Class String JIRA_Key=c.JIRA_Key__c; JIRAWebserviceCalloutSyncFields.Syncfields(JIRA_Key); } } } } Click Save. Button Other than the trigger, you can use the written Apex class for the button. Steps: Write the Apex Class as above. Then, follow the steps in Configuring JIRA Issue Creation Button to create a button, there are slight changes in Step 8 : Label Update JIRA Fields Name Update_JIRA_Status (this is auto-populated when you add a new label) Display Type Detail Page Button Behaviour Execute Javascript Content Source On Click Javascript Content {!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} sforce.apex.execute("JIRAWebserviceCalloutSyncFields","syncfields", jiraKey:"{!Case.JIRA_Key__c}"); window.alert("JIRA issue fields should now be updated."); Now you are ready to test: Create a new Case in JIRA. Use the sync button. You should see a pop-up window: " JIRA Issue fields should now be updated. " Check your JIRA instance to see whether the issue was updated. |
---|
propertyKeys | ["net.customware.confluence.plugin.scaffolding__fdvrbsdku0__data_0_ce7za4tkwb"] |
---|
|