• Ajay mishra
  • NEWBIE
  • 44 Points
  • Member since 2014
  • Salesforce Developer


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 44
    Replies
I need assistance writing APEX code to update the Account Owner based on the following:

Create workflow or process builder to change account owner once "commission end date" (Commission_End_Date__c) has passed. (I've already started the Process Builder, just need to add in the APEX code as the Action)
- If Account Strategist (Account_Strategist__c)(picklist field) is on an account, they are made the account owner. 
- If only a Media Strategist (Media_Strategist__c)(picklist field) is on an account, they are made the account owner. 
- If no Media Strategist or Account Strategist, Client Success (user) are made the account owner. 

I'm assuming I need to make some sort of map that has all of the names and their corresponding Contact IDs. I have the schematics in my mind, I just don't know how to follow through. Any help would be greatly appreciated!!

Best, 
Emily
JavaScript of any type is not allowed to run within the Salesforce.com application context. This includes JavaScript blocks within HomePageComponents, WebLinks, and all other components that are run under the Salesforce.com DOM.

I have Searched for this, some people have suggested below two options: 

1) Convince review team that its false positive as no one can manipulate ID field data
2) Fix the (false positive) Vulnerability by using Encoding function and submit the the package for review again.

I have not found and Encoding Function which support for GETRECORDIDS. Please Suggest If have any idea how to solve.

Thanks in advance 
I need assistance writing APEX code to update the Account Owner based on the following:

Create workflow or process builder to change account owner once "commission end date" (Commission_End_Date__c) has passed. (I've already started the Process Builder, just need to add in the APEX code as the Action)
- If Account Strategist (Account_Strategist__c)(picklist field) is on an account, they are made the account owner. 
- If only a Media Strategist (Media_Strategist__c)(picklist field) is on an account, they are made the account owner. 
- If no Media Strategist or Account Strategist, Client Success (user) are made the account owner. 

I'm assuming I need to make some sort of map that has all of the names and their corresponding Contact IDs. I have the schematics in my mind, I just don't know how to follow through. Any help would be greatly appreciated!!

Best, 
Emily

I completed the Wave Anaytics modules several months back, when the modules only had a quiz. For example, for the "Start Exploring Wave Analytics" module, I prevously earned a perfect score of 100:

User-added image

Now the module was updated, and the quiz was replaced with an actual challenge:

User-added image

I completed the requirements and hit "Check Challenge", however Trailhead reverts back to the original screen showing that I received a score of 100. It does not give me the additional points, nor does it show as fully completed:

User-added image

Start Exploring Wave Analytics should have a green checkmark next to it.

I have posted the link and can see the link on my chatter feed. But when I press the check challenge it cannot see it.

https://trailhead.salesforce.com/modules/lex_salesforce1_basics/units/lex_salesforce1_basics_collab


 
I have Developer Account and want to create TMO to access singuprequest API
I'm working /through the Smart Data Discovey Basics in Trailhead.  In the Import Data exercise, the step below is causing IE to crash.  Any suggestions

User-added image
I have two classes below used for retrieving data using a web call out - this worked when I ran below code in the developer console:
getGPS gps = new getGPS();
gps.getLng();
gps.getLat();

In Log I got longtitude and latitude whci is NOT HAPPENNING NOW FOR SOME REASON.
Can anyone shed a bit of light into this as this is giving me a headache, this ceased to work and I dont know why.

Appreciate your help, Milan

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class getGPS {
    
    String endPointString = 'http://maps.googleapis.com/maps/api/geocode/json?address='Šafaříkova 785/1, 120 00  Praha, Vinohrady';
    double lng;
    double lat;
    
    public double getLng() {
        return lng;
        }
    
    public double getLat() {
        return lat;
        }
    
  

      public void getGPSdata() {
          Http httpProtocol = new Http();
          HttpRequest request = new HttpRequest();
          String endpoint = endPointString;
          request.setEndPoint(endpoint);
          request.setMethod('GET');
          HttpResponse response = httpProtocol.send(request); 
          String jsonString = response.getBody();
          googleAddress addr = googleAddress.parse(jsonString);
          
googleAddress.Location loc = addr.firstLoc;
double lng = loc.lng;
double lat = loc.lat;
          
          this.lng=lng;
          this.lat=lat;

      }
    
                       
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class googleAddress {

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

    public class Geometry {
        public Location location;
        public String location_type;
        public Viewport viewport;
    }

    public List<Results> results;
    public String status;
    public Location firstLoc;

    public class Results {
        public List<Address_components> address_components;
        public String formatted_address;
        public Geometry geometry;
        public Boolean partial_match;
        public String place_id;
        public List<String> types;
    }

    public class Viewport {
        public Location northeast;
        public Location southwest;
    }

    public class Location {
        public Double lat;
        public Double lng;
    }

    
    public static googleAddress parse(String json) {
        
        googleAddress returnAddr;
        
        returnAddr = (googleAddress) System.JSON.deserialize(json, googleAddress.class);
        if (!returnAddr.results.isEmpty()){
            returnAddr.firstLoc = returnAddr.results[0].geometry.location;
        }
        return returnAddr; 
        
        
    }
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Hi all, 

I'm learning triggers in salesforce and want some advice on understanding how to write a trigger for below scenario. what is the approach?
There are two objects Object1_c(Parent) and Object__c(child) having look-up relationship.

Summary:
Object__c has record types namely  "A" and "B".
Object__c has a field (currency) --> Myamount__c
Object__c has 2 picklislts --> Picklist_a__c and Pciklist_b__c
object1__c has a field(curreny_ --> amount__c

Scenario:

when amount__c(on Object1__c) is blank or null, and if record type is either A||B and Picklst_a__c and picklist__b is selected then Myamount__c should be required show be the error.

Thanks in advance.
 
please provide step by step instruction for paypal integration with salesforce

public class OpportunityHelper {
	

public static void CreateURL_SendComingSoonEmail(){
        List<Id> oppsToQuery = new List<Id>();
        for (Tabella_consultazioni__c tc : (List<Tabella_consultazioni__c>)trigger.new){
          //invio email solo se tipologia è uguale a Sessione
			  if(tc.Tipologia__c=='Sessione' ) {
                if (tc.Opportunita__c != NULL && 
                ((Tabella_consultazioni__c)trigger.oldMap.get(tc.Id)).Opportunita__c != tc.Opportunita__c){
                    oppsToQuery.add(tc.Opportunita__c);
                }
            }
        }
        if (oppsToQuery.isEmpty()){
            return;
        }
        List<Messaging.SingleEmailMessage> emailsToSend = new List<Messaging.SingleEmailMessage>();
        List<DatiVersamento__c> dvToInsert = new List<DatiVersamento__c>();
        List<Opportunity> oppsToUpdate = new List<Opportunity>();
        Map<Id, DatiVersamento__c> insertedDVs = new Map<Id, DatiVersamento__c>();
        EmailTemplate emailTemp = [SELECT htmlValue FROM EmailTemplate WHERE name = 'Filippo_ComingSoonTemplate'][0];
        Map<Id, Opportunity> oppQuery = new Map<Id, Opportunity>(
            						[SELECT Id, amount, URL_Dati_Anticipo__c,
                                     Account.FirstName, Account.LastName, Account.PersonEmail
                                     FROM Opportunity WHERE Id IN :oppsToQuery]);
        for (Opportunity opp : oppQuery.values()){
            dvToInsert.add(new DatiVersamento__c(Opportunity__c = opp.Id,
                                                Nome_Paziente__c = opp.Account.FirstName,
                                                Cognome_Paziente__c = opp.Account.LastName));
        }
        insert dvToInsert;
        Site_domain__c sd = Site_domain__c.getInstance();
        String url = sd.URL__c+'DatiVersamento';
        for (DatiVersamento__c dv : dvToInsert){
            insertedDVs.put(dv.Opportunity__c, dv);
        }
        for (Opportunity opp : oppQuery.values()){
            opp.URL_Dati_Anticipo__c = '<a href="'+url+'?Id='+insertedDVs.get(opp.Id).Id+'">'+url+'?Id='+insertedDVs.get(opp.Id).Id+'</a>';
            oppsToUpdate.add(opp);
        }
        update oppsToUpdate;
        for (Tabella_consultazioni__c tc : (List<Tabella_consultazioni__c>)trigger.new){
            if (tc.Opportunita__c != NULL && 
            ((Tabella_consultazioni__c)trigger.oldMap.get(tc.Id)).Opportunita__c != tc.Opportunita__c){
                Opportunity opp = oppQuery.get(tc.Opportunita__c);
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                String body = emailtemp.htmlValue.replace('{!Opportunity.Account}', 
                                                          opp.Account.FirstName+' '+opp.Account.LastName);
                String subject = 'Acconto Sessione bSBS '+opp.Account.FirstName+' '+opp.Account.LastName;
                if (opp.URL_Dati_Anticipo__c == NULL || opp.Account.PersonEmail == NULL){
                    tc.addError('Errore: mancano i campi Email, Url o Amount nella opportunità scelta.');
                }
                body = body.replace('<![CDATA[','');
                body = body.replace(']]>','');
                body = body.replace('{!date}', tc.Data__c.day()+'/'+tc.Data__c.month()+'/'+tc.Data__c.year());
                body = body.replace('{!time}',tc.Ora_inizio_appoggio__c+'.'+tc.Minuto_inizio_appoggio__c);
                body = body.replace('{!IBAN}',IBAN);
                body = body.replace('{!SWIFT}',SWIFT);
                body = body.replace('{!BENEFICIARY}',BENEFICIARY);
                body = body.replace('{!BANK}',BANK);
                body = body.replace('{!subject}',subject);
                body = body.replace('{!amount}','600,00');
                body = body.replace('{!expireDate}',system.Date.today().addDays(2).day()+'/'+system.Date.today().addDays(2).month()+'/'+system.Date.today().addDays(2).year());
                body = body.replace('{!URLdatidacompilare}',opp.URL_Dati_Anticipo__c);
                email.setToAddresses(new List<String>{opp.Account.PersonEmail});
                email.setSubject(subject);
                email.setHtmlBody(body);
                if (opp.Account.PersonEmail == NULL) {
                    continue;
                } else {
                	emailsToSend.add(email);
                }
            }
            
        }
        Messaging.SendEmailResult[] results = Messaging.sendEmail(emailsToSend, TRUE);
        return;
    }
    
    
    public static void PopulateSMSField(){
        List<Id> oppIDsToQuery = new List<Id>();
		for (Tabella_Consultazioni__c tcs : (List<Tabella_Consultazioni__c>)trigger.new){
            	oppIDsToQuery.add(tcs.Opportunita__c);
        }
        Map<Id, Opportunity> oppsToUpdate = new Map<Id, Opportunity>([SELECT Id, OwnerId
                                                FROM Opportunity
                                                WHERE Id IN :oppIDsToQuery]);
        Map<Id, User> users = new Map<Id, User>([SELECT Id, FirstName, LastName
                                                FROM User]);
        Configurazione_SMS__c smsPC = Configurazione_SMS__c.getValues('SMS Prenotazione Consultazione');
        Configurazione_SMS__c smsPS = Configurazione_SMS__c.getValues('SMS Prenotazione Sessione');
        for (Tabella_Consultazioni__c tcs : (List<Tabella_Consultazioni__c>)trigger.new){
            if (tcs.Tipologia__c == 'Consultazione' && tcs.opportunita__c != NULL){
                String str=smsPC.Test_SMS__c;
                str = str.Replace('{!DATA}',FormatDate(System.date.today().day())+'/'+FormatDate(System.date.today().month())+'/'+System.date.today().year());
                str = str.Replace('{!ORA}',FormatDate(system.now().hour())+':'+FormatDate(system.now().minute()));
                str = str.Replace('{!COMMNAME}',users.get(oppsToUpdate.get(tcs.Opportunita__c).OwnerId).FirstName + ' ' + users.get(oppsToUpdate.get(tcs.Opportunita__c).OwnerId).LastName);
            	oppsToUpdate.get(tcs.Opportunita__c).SMS_Prenotazione_Consultazione__c = str;
            } else if (tcs.Tipologia__c == 'Sessione' && tcs.opportunita__c != NULL){
                String str=smsPS.Test_SMS__c+' '+smsPS.Test_SMS_2__c;
                str = str.Replace('{!DATA}',FormatDate(System.date.today().day())+'/'+FormatDate(System.date.today().month())+'/'+System.date.today().year());
                str = str.Replace('{!ORA}',FormatDate(system.now().hour())+':'+FormatDate(system.now().minute()));
                str = str.Replace('{!COMMNAME}',users.get(oppsToUpdate.get(tcs.Opportunita__c).OwnerId).FirstName + ' ' + users.get(oppsToUpdate.get(tcs.Opportunita__c).OwnerId).LastName);
            	oppsToUpdate.get(tcs.Opportunita__c).SMS_Prenotazione_Sessione__c = str;
            }
        }
        update oppsToUpdate.Values();
    }
    
    public static String FormatDate(integer inte){
        if (inte<10){
            return '0'+inte;
        } else{
            return String.ValueOf(inte);
        }
    }
    
    
    public static void PopulateSMSFieldFromDate(){
        Configurazione_SMS__c cSMS = Configurazione_SMS__c.getValues('SMS Conferma Sessione');
        for (Opportunity opp :(List<Opportunity>)trigger.new){
            if( (trigger.isInsert || ( opp.data_pagamento__c != NULL && ((Opportunity)trigger.oldMap.get(opp.Id)).data_pagamento__c == NULL) ) ){
                   opp.SMS_Conferma_Sessione__c = cSMS.Test_SMS__c;
               }
        }
    }
    
}

 

Would it be possibile to filter null long text area fields in SOQL?

I need to run process where if a number of text area fields in contact are null then do something.

Thanks in advance!

 

Challenge Not yet complete... here's what's wrong:
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

My code is:
public class StringArrayTest {
    
    public static List<String> generateStringArray(Integer l)
    {
     List<String> a1=new List<String>();
        for(i=0;i<l;i++)
        {
            a1.add('Test '+i);
            System.debug(a1[i]);
        }
        return a1;
    }


m executing through
StringArrayTest em = new StringArrayTest();
em.generateStringArray(5);

Can anyone help me whats wrong I did here?
Hi Everyone,

My Scenario is create two fields
product category” as the first lookup(Product2) and then the “Product Name/Code” as the second lookup(Product2) into Child Object (Request__c).

Note:  here main problem is reffering same Parent Object(Product2) in Child Object

Here my client expecting first lookup user going to select perticuler Category 

Product Category 
Samsung
IPHONE
SONY

Samsung :(user Clicks First lookup values is Samsung in second lookup need to display some dependeny mentioned below )

Product  Name/code(Lookup)
S-3652
S-2564
S-1234

IPHONE:(user Clicks First lookup values is IPHONE in second lookup need to display some dependeny mentioned below )

Product name/code(Lookup)
I6
I7
I8

Sony:(user Clicks First lookup values is Sony in second lookup need to display some dependeny mentioned below )

Product Name/code(Lookup)
Sony-1234
Sony-5664
Sony-4568

I'm implemented same functionlity using picklist dependency its working fine but my client expecting above scenario. 

Can you please guide me how to achive this scenrion in Salesforce .


PFA

User-added image
Hi All,

Q). One object (s1) & 3 tasks (t1, t2, t3) are there. Each task performing discount related stuff.
   Write a trigger that should calculate the sum of 3 tasks.  And if any task is modified than trigger should fire automatically & perform the same.


Can any one reply for this post..
Thanks in advance
 

Hi,

 

Is there any way to do multiple call outs in a single txn where there are DML operations?