You need to sign in to do that
Don't have an account?
WhiteFusion17
Compare Values from Two Maps
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.
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
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
Therefore the command
myTrelloBoardsMap.get(key) will return an sObject, not a string.
so try a conversion like: in this way you are accessing the field within the sObject
regards
Andrew
p.s. i have just broken it over the multiple lines to make it easier to read and cound brackets ;-)