• WhiteFusion17
  • NEWBIE
  • 10 Points
  • Member since 2020
  • Salesforce Admin

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies

Hello I want to a take a custom of a customised org to another developer enviroment which is not connected.

I have pulled the metadata via VS code and the Manifest but I want to restore this to another Dev Org.

When I try to restore I get lots if dependancy errors.

Is there anyway around this ?

Also what about installed Packages how do I deal with this

Hello I want to use a static resource for my Mock but I cannot get it to work where am I going wrong based on this snippet of code:
 
@isTest
global class TrelloAPICalloutClass_Mock implements HttpCalloutMock {

    public static HttpResponse res;
    public static HttpRequest req;
    private String whichMock;

    public TrelloAPICalloutClass_Mock (String mockNeeded){
        this.whichMock = mockNeeded;
    }

    global HTTPResponse respond(HTTPRequest req){
        res = new HttpResponse();
        switch on whichMock {
            when 'createboards' {
                createBoardMock();
            }
            when 'getattachment' {
                attachmentMock();
            }
            when 'gettrelloboards' {
                getTrelloBoardsMock();
            }
            when 'getTrelloListsFromBoardMock' {
                getTrelloListsFromBoardMock();
            }
            when 'getTrelloLabelsFromBoardsMock' {
                getTrelloLabelsFromBoardsMock();
            }
            when 'getTrelloBoardsMockError' {
                getTrelloBoardsMockError();
            }
            when 'getTrelloBoardsMockNewBoard' {
                getTrelloBoardsMockNewBoard();
            }
            when 'getTrelloBoardsMockUpdateName' {
                getTrelloBoardsMockUpdateName();
            }
            when 'getTrelloListsFromBoardMockNewList' {
                getTrelloListsFromBoardMockNewList();
            }
        }
        return res;        
        
    }

    private static void getTrelloBoardsMock(){
        // Get The Trello Boards
        StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
        mock.setStaticResource('getOrgBoards');
        mock.setHeader('Content-Type', 'application/json');
        mock.setStatusCode(200);
        Test.setMock(HttpCalloutMock.class, mock);
    }

I have no doubt it is to do with the res vs the mock but I cannot work out the issue
Basically I need to compare the ID value from map to another but the returned map from the SOQL will not work so im trying to build a new map with the Trello_board_ID__C as the key and the name as the value.

But I cannot get it to work, It looks like the GET will only work with the key so this is the reason I think my code returns a null value on the compareTrelloBoard map.
 
public static void manageTheBoards (){ //will need to change back to private after testing
        // manages on how we deal with the board updates
        Map<string, trello_boards__C> myTrelloBoardsMap = new Map<string, trello_boards__C>(
                                                [SELECT  Id, Trello_Board_Id__c , name
                                                FROM Trello_Boards__c
                                                ]);

        System.debug('My Trello Boards Map = ' +myTrelloBoardsMap);

        map<string, string> compareTrelloBoard = new map <string, string>();

        for (string key : myTrelloBoardsMap.keyset()) {
            compareTrelloBoard.put(String.valueOf(myTrelloBoardsMap.get('Trello_Board_Id__c')),String.valueOf(myTrelloBoardsMap.get('Name')));
        }


        //System.debug('myTrelloboards = ' + myTrelloBoards);
        System.debug('boardNameWithID = ' + boardNameWithId);
        System.debug('MyTrello Boards = ' + compareTrelloBoard);

        //for (string boardName : boardNameWithID.keyset()) {
            //if (!myTrelloBoards.containsKey(boardName)) {
            }
        }

Basically I want to convert my myTrelloBoardsMap to a <string, string> map with the trello_board_id__C as the key and the Name as the value.
I can then use this to compare the lists and update / delete / create new values in my salesforce list if they match or don't match
Hello I have the below code but i cannot use the if statement basically when I use the if statement it no longers see the labelsIds (list variable) if I declare it in the method then it sees it as null so this does not work either.

It's all related to variable scope. 

I sure this is easy to fix but cannot work it out.
 
public static void trelloCreateNew(String ticketId, String incomingListId, String incomingLabelsID){
        listId = incomingListId;
        System.debug('Incoming Label IDs = ' +incomingLabelsID);

        //If (null == incomingLabelsID){
        List<String> labelIds = incomingLabelsID.split('; ');
        System.debug('labelids = ' +labelIds);
        //}else{
        //    list<string> labelIds = null;
        //} <--- this commented out code breaks if used

    	// Get the ticket details
    	ticket = [
                SELECT Id, Name, Trello_Card_Title__c, Trello_Card_Description__c, Trello_Card_URL__C, Trello_Card_Raised__C 
                FROM Ticketing__c 
                WHERE Id = :ticketId
        ];
        String fullticketURL = URL.getSalesforceBaseUrl().toExternalForm() +
         '/' + ticket.id;

        //Debug statements not needed in Live
    	System.debug('The ticket id = '+ticket.Id 
                     +'\n The Ticket number is '+ ticket.Name 
                     + '\n The Trello card title is '+ ticket.trello_card_title__C
                     + '\n The trello card description is ' + ticket.Trello_Card_Description__c
                     + '\n The Ticket Full URL is ' +fullticketURL);
    
    
    	endpointURL = getEnpointURL('NEWCARD');

        String requestbody;
        System.debug('labelids='+labelIds);
        if (labelIds.size() >= 1) {  <- USED HERE
            requestBody = '{"desc":'
            + Json.serialize(ticket.Trello_Card_Description__c)
            + ',"idLabels":' 
            +  Json.serialize(labelIds)             
            +'}';    
        } else {
            requestBody = '{"desc":'
            + Json.serialize(ticket.Trello_Card_Description__c)       
            +'}';    
        }

Cheers in advance for the help as always !!!
Hello I have several web call outs to Trello that return the boards, the lists and the labels. I want to use these in a flow to create a new Trello card but all these methods are future methods. What is the best approach for saving the values to use in a flow and using these methods to keep the lists up to date.

so basically the flow would look like this

 1. what board do you want to save to ( names and id's returned from future method call out)

 2. what list on this board ( takes the ID of the board and feeds it to the out bound future method and returns the name and id's of lists)

 3 what's the name and description (takes the ids from step 1 and 2 and puts sends an outbound post request to Trello to create the card)

4 do you want to add any labels ( returns the us of the card and the updates with the labels returned from Trello )

my thoughts are maybe custom meta data types then launch the future methods as batches to keep them updated  

if you have a better solution please let me know !!!
Basically i have the following loop and when i run it through process builder i get the bottom error:

The code is below
 
public with sharing class TrelloInvocable {
    /**
     * @description     Create a list and runs that through the Trello API Callout Class
     * @param           ticketIds is the list that is presented to the method
    */
    @InvocableMethod(label='Create trello cards' description='Will attempt to Create a new trello card for each id')
	public static void TrelloInvocableMethod (List<Id> ids){
        for (Id id : ids){
            System.debug(id);
            TrelloAPICalloutClass.trellocreatenew(id);
        }
  }
}

It fires this code:
 
public static void trellocreatenew(string ID){
        
        	// Get the ticket details
        	Ticketing__C ticket = [SELECT id,name,Trello_Card_Title__c,Trello_Card_Description__c,trello_card_URL__C,Trello_Card_Raised__C 
                                   FROM ticketing__C 
                                   Where ID = :ID];
        	system.debug('The ticket id = '+ticket.id 
                         +'\n The Ticket number is'+ ticket.Name 
                         + '\n The Trello card title is '+ ticket.trello_card_title__C
                         + '\n The trello card description is ' + ticket.Trello_Card_Description__c);
        
        
        	// get connection details from custom settings
        	TrelloConnectionDetails__c connection = TrelloConnectionDetails__c.getOrgDefaults();
        	string key = connection.Key__c;
        	string token = connection.Token__c;
        	string idlist = connection.Id_List__c;
        	string name = encodingUtil.urlEncode(ticket.Trello_Card_Title__c, 'UTF-8');
        	string postcardurl = connection.PostCard__c;
        	string endpointurl = postcardurl.replace('{key}', key)
                							.replace('{token}', token)
                							.replace('{name}',name)
                							.replace('{idlist}', idlist);
            string body = '{"desc":'
                			+ Json.serialize(ticket.Trello_Card_Description__c)
                			+'}';
    		system.debug(body);
        	system.debug(endpointurl);
        
 
        	//submit the http request to trello
            HttpRequest request = new HttpRequest();
            http http = new Http();
            request.setEndpoint(endpointurl);
            request.setMethod('POST');
            request.setHeader('Content-Type', 'application/json;charset=UTF-8');
            request.setBody(+body);
            HttpResponse response = http.send(request);
        
            //check if we get a good response from trello
            if (response.getstatuscode() == 200){
                //Deserializes the JSON string into collections of primitive data types
                Map <string, Object> results = (map<string, object>) json.deserializeUntyped(response.getBody());
                system.debug(results);
                    if(results.containsKey('shortUrl')){
                    string returnedURL = String.valueOf(results.get('shortUrl'));
                    ticket.Trello_Card_URL__c = returnedURL;
                    system.debug(returnedURL);
                    //Update ticket;
                    }
             } Else {
                  System.debug('The status code returned was not expected: ' +
                    response.getStatusCode() + ' ' + response.getStatus());
                 }
            
            
              
        }
            
    }

However it gives this error:

We can't save this record because the “Assign new ticket to a Inbound Ticket Queue” process failed. Give your Salesforce admin these details. An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out Error ID: 1425857253-83851 (194658065)

Any help would be fab as i do not understand the issue.

This is my first shot at apex so if it simple i do appologise.

Hello I'm doing a rest post request to Trello to create a card however the http.sendbody is giving me issues basically I have to send  a string value but need to ensure it can support line breaks and is in JSON.

is there a method I can use to present the format in JSON ? The format should be ["desc", "VAlue from custom object"]


Value from the custom object should use \n for line breaks

any help would be amazing 
 

Hello I want to use a static resource for my Mock but I cannot get it to work where am I going wrong based on this snippet of code:
 
@isTest
global class TrelloAPICalloutClass_Mock implements HttpCalloutMock {

    public static HttpResponse res;
    public static HttpRequest req;
    private String whichMock;

    public TrelloAPICalloutClass_Mock (String mockNeeded){
        this.whichMock = mockNeeded;
    }

    global HTTPResponse respond(HTTPRequest req){
        res = new HttpResponse();
        switch on whichMock {
            when 'createboards' {
                createBoardMock();
            }
            when 'getattachment' {
                attachmentMock();
            }
            when 'gettrelloboards' {
                getTrelloBoardsMock();
            }
            when 'getTrelloListsFromBoardMock' {
                getTrelloListsFromBoardMock();
            }
            when 'getTrelloLabelsFromBoardsMock' {
                getTrelloLabelsFromBoardsMock();
            }
            when 'getTrelloBoardsMockError' {
                getTrelloBoardsMockError();
            }
            when 'getTrelloBoardsMockNewBoard' {
                getTrelloBoardsMockNewBoard();
            }
            when 'getTrelloBoardsMockUpdateName' {
                getTrelloBoardsMockUpdateName();
            }
            when 'getTrelloListsFromBoardMockNewList' {
                getTrelloListsFromBoardMockNewList();
            }
        }
        return res;        
        
    }

    private static void getTrelloBoardsMock(){
        // Get The Trello Boards
        StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
        mock.setStaticResource('getOrgBoards');
        mock.setHeader('Content-Type', 'application/json');
        mock.setStatusCode(200);
        Test.setMock(HttpCalloutMock.class, mock);
    }

I have no doubt it is to do with the res vs the mock but I cannot work out the issue
Hello I have several web call outs to Trello that return the boards, the lists and the labels. I want to use these in a flow to create a new Trello card but all these methods are future methods. What is the best approach for saving the values to use in a flow and using these methods to keep the lists up to date.

so basically the flow would look like this

 1. what board do you want to save to ( names and id's returned from future method call out)

 2. what list on this board ( takes the ID of the board and feeds it to the out bound future method and returns the name and id's of lists)

 3 what's the name and description (takes the ids from step 1 and 2 and puts sends an outbound post request to Trello to create the card)

4 do you want to add any labels ( returns the us of the card and the updates with the labels returned from Trello )

my thoughts are maybe custom meta data types then launch the future methods as batches to keep them updated  

if you have a better solution please let me know !!!
Basically i have the following loop and when i run it through process builder i get the bottom error:

The code is below
 
public with sharing class TrelloInvocable {
    /**
     * @description     Create a list and runs that through the Trello API Callout Class
     * @param           ticketIds is the list that is presented to the method
    */
    @InvocableMethod(label='Create trello cards' description='Will attempt to Create a new trello card for each id')
	public static void TrelloInvocableMethod (List<Id> ids){
        for (Id id : ids){
            System.debug(id);
            TrelloAPICalloutClass.trellocreatenew(id);
        }
  }
}

It fires this code:
 
public static void trellocreatenew(string ID){
        
        	// Get the ticket details
        	Ticketing__C ticket = [SELECT id,name,Trello_Card_Title__c,Trello_Card_Description__c,trello_card_URL__C,Trello_Card_Raised__C 
                                   FROM ticketing__C 
                                   Where ID = :ID];
        	system.debug('The ticket id = '+ticket.id 
                         +'\n The Ticket number is'+ ticket.Name 
                         + '\n The Trello card title is '+ ticket.trello_card_title__C
                         + '\n The trello card description is ' + ticket.Trello_Card_Description__c);
        
        
        	// get connection details from custom settings
        	TrelloConnectionDetails__c connection = TrelloConnectionDetails__c.getOrgDefaults();
        	string key = connection.Key__c;
        	string token = connection.Token__c;
        	string idlist = connection.Id_List__c;
        	string name = encodingUtil.urlEncode(ticket.Trello_Card_Title__c, 'UTF-8');
        	string postcardurl = connection.PostCard__c;
        	string endpointurl = postcardurl.replace('{key}', key)
                							.replace('{token}', token)
                							.replace('{name}',name)
                							.replace('{idlist}', idlist);
            string body = '{"desc":'
                			+ Json.serialize(ticket.Trello_Card_Description__c)
                			+'}';
    		system.debug(body);
        	system.debug(endpointurl);
        
 
        	//submit the http request to trello
            HttpRequest request = new HttpRequest();
            http http = new Http();
            request.setEndpoint(endpointurl);
            request.setMethod('POST');
            request.setHeader('Content-Type', 'application/json;charset=UTF-8');
            request.setBody(+body);
            HttpResponse response = http.send(request);
        
            //check if we get a good response from trello
            if (response.getstatuscode() == 200){
                //Deserializes the JSON string into collections of primitive data types
                Map <string, Object> results = (map<string, object>) json.deserializeUntyped(response.getBody());
                system.debug(results);
                    if(results.containsKey('shortUrl')){
                    string returnedURL = String.valueOf(results.get('shortUrl'));
                    ticket.Trello_Card_URL__c = returnedURL;
                    system.debug(returnedURL);
                    //Update ticket;
                    }
             } Else {
                  System.debug('The status code returned was not expected: ' +
                    response.getStatusCode() + ' ' + response.getStatus());
                 }
            
            
              
        }
            
    }

However it gives this error:

We can't save this record because the “Assign new ticket to a Inbound Ticket Queue” process failed. Give your Salesforce admin these details. An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out Error ID: 1425857253-83851 (194658065)

Any help would be fab as i do not understand the issue.

This is my first shot at apex so if it simple i do appologise.

Hello I'm doing a rest post request to Trello to create a card however the http.sendbody is giving me issues basically I have to send  a string value but need to ensure it can support line breaks and is in JSON.

is there a method I can use to present the format in JSON ? The format should be ["desc", "VAlue from custom object"]


Value from the custom object should use \n for line breaks

any help would be amazing