• Rohit Goyal 5
  • NEWBIE
  • -1 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
When I'm trying to use 
> sfdx force:auth:web:login -d -a DevHub
Getting Error - 
ERROR running force:auth:web:login:  Cannot start the OAuth redirect server on port PortInUseAction. 

Try this: 
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.

 
When I'm trying to use 
> sfdx force:auth:web:login -d -a DevHub
Getting Error - 
ERROR running force:auth:web:login:  Cannot start the OAuth redirect server on port PortInUseAction. 

Try this: 
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.

 

Hello, I am receiving the Error "system.limitexception too many future calls 51" when I Inserted 300+ records in our Org. I would like an assistance to get around this Error. I hope someone can help here.. I am new to Apex Code for Callouts.. Here's my code.


TRIGGER:

trigger SG_ContactTriggers on Contact (after insert) {

    //TriggerHandler
    TriggerHandlerREST handler = new TriggerHandlerREST();
    
    if(trigger.isAfter){
        handler.UPDATE_CONTACT_ADDRESS(trigger.new);
    }
}


And Here's my CLASS​

public class TriggerHandlerREST {
    //GET GEOCODE METHOD
    public void UPDATE_CONTACT_ADDRESS(List<contact> newContacts){
        
        List<contact> contactsToUpdate = new List<contact>();
        for(contact contacts : [select id, MailingPostalCode from contact where id in: newContacts]){
            
        	GET_GEOCODE(contacts.MailingPostalCode,contacts.id);
        
        }
    }
    
    @future(callout=true)
    public static void GET_GEOCODE(String POSTAL_CODE,string contactID){
        
        contact con = [select id,MailingCity,MailingState,MailingCountry from contact where id =:contactId];
        
        
        String ENDPOINT = 'https://maps.google.com/maps/api/geocode/json?key=AIzaSyAGXR9Ybwo_YxMQvyb-XRP_36fT5_wkeFU&components=country:AU|postal_code:'+POSTAL_CODE+'&sensor=false';
            try{
                HTTPRequest request = new HTTPRequest();
                request.setEndpoint(ENDPOINT);
                request.setHeader('Content-Type', 'application/json');
                request.setMethod('GET');
                
                HTTP http = new HTTP();
                HTTPResponse  response =  http.send(request);
                
                GeoCodeResult geo =(GeoCodeResult)JSON.deserialize(response.getBody(),GeoCodeResult.class);
                
                if(geo.status == 'OK'){
                for(Results results : geo.results){
                    for( Address_components address : results.address_Components){
                        if(address.types.get(0)=='locality'){con.MailingCity=address.long_name;}else if(address.types.get(0)=='administrative_area_level_1'){con.MailingState=address.long_name;}else if(address.types.get(0)=='country'){ con.MailingCountry=address.long_name; }
                    }
                }
                    update con; //UPDATE THE CONTACT
                    
                } else { system.debug('@NUR results === '+geo.status);}
   				
            }catch(Exception e){
               String errorMessage='';
               errorMessage=e.getMessage();
               errorMessage+= ' ::: inside updateAddressByGeocode.getUserByEmail(string email)  ....';
            }
    }
    
    /////HELPER CLASS
    public class GeoCodeResult {
        public List<Results> results;
        public String status;

    }
    
    public class Address_components {
        public String long_name;
        public String short_name;
        public List<String> types;
    }
    
    public class Results {
        public List<Address_components> address_components;
    }
}


Thank you so much in Advance!
Hi there,

I have a trigger to keep Opportunity and Quote Line Items custom field synced. In this process I compare some of the fields of QuoteLineItem and OpportunityLineItem (to find out which ones are corresponding). So I query the items and check for some fields, including UnitPrice. When the user's profile currency is different from the related records currency, the UnitPrice is being converted in one of the objects (QuoteLineItem), but not in the other (OpportunityLineItem), so my mapping fails and my trigger does nothing because it couldn't find a matching item to sync fields. These are the queries my trigger does:
 
String qliQuery = 'select Id, QuoteId, PricebookEntryId, UnitPrice, Quantity, SortOrder, CurrencyIsoCode' + qliFields + ' from QuoteLineItem where Id in (' + qliIds + ') order by QuoteId, SortOrder ASC';
List<QuoteLineItem> qlis = Database.query(qliQuery);

String oliQuery = 'select Id, OpportunityId, PricebookEntryId, UnitPrice, Quantity, SortOrder, CurrencyIsoCode' + oliFields + ' from OpportunityLineItem where OpportunityId in (' + oppIds + ') order by OpportunityId, SortOrder ASC';
List<OpportunityLineItem> olis = Database.query(oliQuery);
Where qliFields and oliFields define which custom fields will be synced, qliIds contains the new QuoteLineItems being created, and oppIds are the IDs of the Opportunities related to the entries that fired this trigger.

These queries are done in an after insert context in the QuoteLineItem object. The result of the both queries is below (I ommited some of the irrelevant fields):
 
[Debug] COMPARING: QuoteLineItem:{Id=0QLc0000002mkaVGAQ, QuoteId=0Q0c0000000acKFCAY, PricebookEntryId=01u0B00000rRLZmQAO, UnitPrice=2855.60, Quantity=1.00, CurrencyIsoCode=USD, ...}

[Debug] COMPARING: OpportunityLineItem:{Id=00kc000000AREWCAA5, OpportunityId=006c000000GFc4SAAT, PricebookEntryId=01u0B00000rRLZmQAO, UnitPrice=1298.00, Quantity=1.00, CurrencyIsoCode=USD, ...}
Note that UnitPrice is returning 2855.60 in this query (which is 1298.00 * 2.20, our default currency conversion rate). Although, both records are registered with CurrencyIsoCode as USD (as they should be). All other records (Opportunity, Quote, PricebookEntry) are registered as USD.

So, when comparing by UnitPrice, those two records never match and my trigger fails its goal. I will remove this comparison and use other criteria for matching, so my problem will be solved for now, but I would like very much to understand this behavior.

​Any help? Thanks in advance.