I am trying to synchronize salesforce task comments to Jira issues comments and I am getting the following error when I am trying to save the apex class:
Error: Compile Error: No such column 'Assignee__c' on entity 'Task'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 9 column 21
I have the following Apex class:
global class JIRATaskWebserviceCalloutSyncFields {
@future (callout=true)
WebService static void syncfields(String JIRA_Key) {
//Modify these variables:
String username = 'yourusername';
String password = 'yourpassword';
String jiraURL = ' http://youjiraurl.com';
sObject s = [SELECT Subject, Assignee__c, Priority, Requested_By__c FROM Task 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());
}
}
}
In the error, the line 9 with the Assignee__C is basically a case field(apex class is also designed for case, and I replaced the case with Task),I trying to clone this onto Task. And Task doesn't have the Assignee__C field. How can get rid of this criteria in order to save the class