• Harshala Godse 1
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
SON ERROR - Null argument for JSONGenerator.writeStringField()
Here's my code for creating, I used this code to update JIRA from salesforce*****************




@RestResource(urlMapping='/test*****/*')
global without sharing class JiraIssueController {
    
    @future(callout=true)   
    global static void JiraIssueController(List<Id> rocStarId){
        //let's first query details on the recently created Jira Issue record
            list<ROC_Star__c> RocStars = [SELECT Id,Summary__c,Priority__c,Description__c,Type__c
                                         FROM ROC_Star__c
                                         WHERE ID IN :rocStarId];
        
        //let's instantiate a JSONGenerator and fill out details inside a For loop below
        String jiraSFDCCustomURLField = label.Jira_SFDC_URL_Custom_Field;
        JSONGenerator gen = JSON.createGenerator(true);
        for(ROC_Star__c rs : RocStars){
            String SForceURL = label.Jira_SForceURL + rs.id;
            system.debug('SForceURL: ' + SForceURL);
            gen.writeStartObject();
            gen.writeFieldName('fields');
            gen.writeStartObject();
            gen.writeFieldName('project');
            gen.writeStartObject();
            gen.writeStringField('key','ROC');
            gen.writeEndObject();
            gen.writeStringField(jiraSFDCCustomURLField,SForceURL);
            gen.writeStringField('summary',rs.Summary__c);
            gen.writeStringField('description', rs.Description__c);
            gen.writeFieldName('issuetype');
            gen.writeStartObject();
            gen.writeStringField('name',rs.Type__c);
            gen.writeEndObject();
            gen.writeFieldName('priority');
            gen.writeStartObject();
            gen.writeStringField('name',rs.Priority__c);
            gen.writeEndObject();
            gen.writeEndObject();
        }
        string s = gen.getAsString();
        system.debug(s);
        //now that our JSON message is ready to send to Jira
        //let's prepare an HTTPRequest and HTTPResponse to send via REST Api
        
        String username = label.Jira_Username; // username can be manipulated through Setup UI;
        String password = label.Jira_Token; // token can be manipulated through Setup UI 
        String auth_header = 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(username + ':' + password));
        string url = label.Jira_IssueRestURL;
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept','application/json');
        req.setHeader('Authorization', auth_header);
        req.setHeader('X-Atlassian-Token', 'nocheck');
        req.setMethod('POST');
        req.setBody(s);
        req.setEndpoint(url);
        HttpResponse res = http.send(req); 
        system.debug('res ' + res);
        // Log the JSON content
        System.debug('******************JSON Response Start********************************');
        System.debug('JSON Response: ' + res.getBody()); 
        System.debug('******************JSON Response End***********************************');
        System.debug('response: ' + res);
        String JSONContent = res.getBody(); 
                
        Map<String,String> values = (Map<String,String>)
            JSON.deserialize(JSONContent, Map<String,String>.class);
        String key = values.get('key');
        String self = values.get('self');

        list<ROC_Star__c> RocStarsToUpdate = new list<ROC_Star__c>();
        for(ROC_Star__c rs : RocStars){
            rs.jira_key__c            = key;
            rs.Jira_Issue_Rest_URL__c = self;
            RocStarsToUpdate.add(rs);
            }
        Database.update(RocStarsToUpdate,false);
        
        }
    
    @future(callout=true)
    global static void JiraAssignIssue(list<id> rocStarsToUpdate){
        Map<String,String> jiraUserMap = new Map<String,String>();
            jiraUserMap.put('Cesar Bohorquez','5db75640fc11e40c2ff3f052');
            jiraUserMap.put('Sergio Gallegos','5dcf03a237249a0c693071c2');
            jiraUserMap.put('Anthony Jacovino','5df8f383eaf5880cad03734c');
            jiraUserMap.put('Joe Williams','5ced7740e2e3ec0fc196cf69');
            jiraUserMap.put('Michael Smith','5ec57e930363340c0f97faeb');        
        String jiraKey;
        //let's first query details on the recently created Jira Issue record
        list<ROC_Star__c> RocStars = [SELECT Id,Priority__c,Description__c,Type__c,Jira_Key__c,Assigned__r.Name
                                         FROM ROC_Star__c
                                         WHERE ID IN :rocStarsToUpdate
                                         LIMIT 1];
        //let's instantiate a JSONGenerator and fill out details inside a For loop below
        JSONGenerator gen = JSON.createGenerator(true);
        for(ROC_Star__c rs : RocStars){
            jiraKey = rs.Jira_Key__c;
            gen.writeStartObject();
            gen.writeStringField('accountId',jiraUserMap.get(rs.Assigned__r.Name));
            gen.writeEndObject();
        }
        system.debug(jiraKey);
        string s = gen.getAsString();
        system.debug(s);
        //now that our JSON message is ready to send to Jira
        //let's prepare an HTTPRequest and HTTPResponse to send via REST Api
        
        String username = label.Jira_Username; // username can be manipulated through Setup UI;
        String password = label.Jira_Token; // token can be manipulated through Setup UI 
        String auth_header = 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(username + ':' + password));
        string url = label.Jira_IssueRestURL + jiraKey + '/assignee';
        
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept','application/json');
        req.setHeader('Authorization', auth_header);
        req.setHeader('X-Atlassian-Token', 'nocheck');
        req.setMethod('PUT');
        req.setBody(s);
        req.setEndpoint(url);
        HttpResponse res = http.send(req); 

        // Log the JSON content
        System.debug('******************JSON Response Start********************************');
        System.debug('JSON Response: ' + res.getBody()); 
        System.debug('******************JSON Response End***********************************');
        System.debug('response: ' + res);
        String JSONContent = res.getBody();        
        }
    
    @future(callout=true)
    global static void JiraUpdatePriority(list<id> rocStarsToUpdate){
        String jiraKey;
        //let's first query details on the recently created Jira Issue record
        list<ROC_Star__c> RocStars = [SELECT Id,Priority__c,Description__c,Type__c,Jira_Key__c,Assigned__r.Name
                                         FROM ROC_Star__c
                                         WHERE ID IN :rocStarsToUpdate
                                         LIMIT 1];
        //let's instantiate a JSONGenerator and fill out details inside a For loop below
        JSONGenerator gen = JSON.createGenerator(true);
        for(ROC_Star__c rs : RocStars){
            jiraKey = rs.Jira_Key__c;
            gen.writeStartObject();
            gen.writeFieldName('update');
            gen.writeStartObject();
            gen.writeFieldName('priority');
            gen.writeStartArray();
            gen.writeStartObject();
            gen.writeFieldName('set');
            gen.writeStartObject();
            gen.writeStringField('name', rs.Priority__c);      
            gen.writeEndObject();
            gen.writeEndObject();
            gen.writeEndArray();
            gen.writeEndObject();
            gen.writeEndObject();
        }
        system.debug(jiraKey);
        string s = gen.getAsString();
        system.debug(s);
        //now that our JSON message is ready to send to Jira
        //let's prepare an HTTPRequest and HTTPResponse to send via REST Api
        
        String username = label.Jira_Username; // username can be manipulated through Setup UI;
        String password = label.Jira_Token; // token can be manipulated through Setup UI 
        String auth_header = 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(username + ':' + password));
        string url = label.Jira_IssueRestURL + jiraKey;
        
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept','application/json');
        req.setHeader('Authorization', auth_header);
        req.setHeader('X-Atlassian-Token', 'nocheck');
        req.setMethod('PUT');
        req.setBody(s);
        req.setEndpoint(url);
        HttpResponse res = http.send(req); 

        // Log the JSON content
        System.debug('******************JSON Response Start********************************');
        System.debug('JSON Response: ' + res.getBody()); 
        System.debug('******************JSON Response End***********************************');
        System.debug('response: ' + res);
        String JSONContent = res.getBody();        
        }
    
    @future(callout=true)
    global static void JiraUpdateStatus(list<id> rocStarsToUpdate){
        Map<String,integer> jiraStatusMap = new Map<String,integer>();
        integer backlogId    = integer.valueOf(label.JiraBacklogId);
        integer inProgressId = integer.valueOf(label.JiraInProgressId);
        integer doneId       = integer.valueOf(label.JiraDoneId);
        jiraStatusMap.put('Backlog',backlogId);
        jiraStatusMap.put('In Progress',inProgressId);
        jiraStatusMap.put('Done',doneId);
        
        String jiraKey;
        //let's first query details on the recently created Jira Issue record
        list<ROC_Star__c> RocStars = [SELECT Id,Status__c,Jira_Key__c
                                         FROM ROC_Star__c
                                         WHERE ID IN :rocStarsToUpdate
                                         LIMIT 1];
        //let's instantiate a JSONGenerator and fill out details inside a For loop below
        JSONGenerator gen = JSON.createGenerator(true);
        for(ROC_Star__c rs : RocStars){
            jiraKey = rs.Jira_Key__c;
            integer statusId = jiraStatusMap.get(rs.Status__c);
            gen.writeStartObject();
            gen.writeFieldName('transition');
            gen.writeStartObject();
            gen.writeNumberField('id', statusId);      
            gen.writeEndObject();
            gen.writeEndObject();
        }
        system.debug(jiraKey);
        string s = gen.getAsString();
        system.debug(s);
        //now that our JSON message is ready to send to Jira
        //let's prepare an HTTPRequest and HTTPResponse to send via REST Api
        
        String username = label.Jira_Username; // username can be manipulated through Setup UI;
        String password = label.Jira_Token; // token can be manipulated through Setup UI 
        String auth_header = 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(username + ':' + password));
        string url = label.Jira_IssueRestURL + jiraKey + '/transitions';
               
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept','application/json');
        req.setHeader('Authorization', auth_header);
        req.setHeader('X-Atlassian-Token', 'nocheck');
        req.setMethod('POST');
        req.setBody(s);
        req.setEndpoint(url);
        HttpResponse res = http.send(req); 

        // Log the JSON content
        System.debug('******************JSON Response Start********************************');
        System.debug('JSON Response: ' + res.getBody()); 
        System.debug('******************JSON Response End***********************************');
        System.debug('response: ' + res);
        String JSONContent = res.getBody();        
        } 
    }
·
 
ADP company news and announcement  Integrate with SalesForce. Do we have the option to integrate with ADP or any free or min pay app in-app exchange?
ADP company news and announcement  Integrate with SalesForce. Do we have the option to integrate with ADP or any free or min pay app in-app exchange?
I'm trying to write an apex program that would automatically update the development status on an SFDC case when the Jira issue status is updated, but am a little lost. I was thinking a trigger could work, but I don't think an apex trigger can be activated from a third party object. Any suggestions/thoughts are greatly appreciated!
I'm writing a flow to query a custom object and assign new values to update to the User object and I keep getting an error that says "number of iterations exceeded". I made sure to put my lookup and update outside of the loop but it doesn't seem to matter. The initial lookup returns about 1800 records but if I limit the lookup to 40 or so records, it does seem to work. Is there anyway I can modify the flow so it doesn't throw the iteration error? A partial error log and a screencap of my flow are below. Thanks!
###
Error element Flag_Deposit_User_Checkbox_for_Single_User_Record (FlowAssignment).
Number of iterations exceeded

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.

Flow Details
Flow Name: Check_Deposit_Users_Box_Flow_2
Type: Flow
Version: 5
Status: Active

Flow Interview Details
Interview Label: Check Deposit Users Box Flow 2 4/6/2017 6:11 AM
Current User: John Dinkeloo (005G0000001sTS5)
Start time: 4/6/2017 6:11 AM
Duration: 2 seconds

How the Interview Started
John Dinkeloo (005G0000001sTS5) started the flow interview.

FAST LOOKUP: Find_all_Account_Owners_with_User_Account
Find all LiveOak__Account_Owner__c records where:
LiveOak__User__c Is null false
Assign those records to {!coll_AccountOwnerWithUser}.
Save these field values in the variable: LiveOak__User__c, Id
Result
Successfully found records.

LOOP: Loop_Thru_Account_Owner_Records
Loop Through: [a2AG000000hAbrnMAC,a2AG000000hAbs2MAC,a2AG000000hAbsbMAC,a2AG000000hAbsgMAC,a2AG000000hAbslMAC,a2AG000000hAbtA (I had to edit out most of the 1800 records returned here because I was exceeding the character limit)]
Iteration: 0
Current value of {!single_AccountOwner}: a2AG000000hAbrnMAC

ASSIGNMENT: Assign_ID_to_Single_User_Record
{!single_UserRecord.Id} Equals {!single_AccountOwner.LiveOak__User__c}
Result
{!single_UserRecord.Id} = "005G0000008xVeWIAU"

ASSIGNMENT: Flag_Deposit_User_Checkbox_for_Single_User_Record
{!single_UserRecord.IsDepositUser__c} Equals true
Result
{!single_UserRecord.IsDepositUser__c} = "true"

ASSIGNMENT: Add_single_record_to_Use_collection
{!coll_UserRecords} Add {!single_UserRecord}
Result
{!coll_UserRecords} = "[005G0000008xVeWIAU]"
###
User-added image
Trailhead recently enhanced new UI and language. In my case, it automatically swapped from English to French. Nonetheless, as I work mainly in English, I would rather having the ability to use Trailhead in English or French upon request.
I didn't find the way to switch from one to the other language.
Has somebody any idea how to tune this feature, by chance?
Best regards