• Gupta.Vishal
  • NEWBIE
  • 220 Points
  • Member since 2013
  • Senior Salesforce Developer
  • Model N

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 43
    Replies
Hi All, 

I would like to know if there is a possibility to deploy the process builder with active status in any way of deployment?. Currently I am facing the issue like is it was deployed through Ant migration tool with inactive status. So, I have to manually activate it after deployment.

Thanks in Advance!
Can you help me on this? I have tried over and over! I get this error message on this Trailhead "Secure Your Users Identity":

Can't assign permission set Trailhead to user Sia Thripio. The user license doesn't allow the permission: Manage Two-Factor Authentication in User Interface

Any Ideas?
Hi All,
I have one simple map like below.
Map<string,string> keyAndValues = new Map<string,string>();
keyAndValues.put('ABCD','1234');

Now i want to check whether the string 'abcd' exists in Keys of Map or not.
I ll write like this,
if(keyAndValues.containskey('abcd')){
    system.debug('Key exists in map');
}

Here It will return false as it ll check with case sensitivity.

But i want to ignore case sensitivity and want to search vth case insensivity.Is there any way to do like this.
If any one have idea please let me know.


Thanks in Advance.

Rajesh.
  • March 31, 2014
  • Like
  • 0
Greetings everyone,

I'm in the process of converting all of my triggers to classes (and then calling them in a main trigger for each object).

Anywho, I'm trying to convert an Account trigger that transfers an account's contacts to the current account owner, but I'm getting an error with the line that references "trigger.oldMap". What do I have to do in these instances going forward? Please see the trigger and error message below.

Thanks!

User-added image

User-added image


Let me know if you need any other info from me!

Thanks!
-Greg
Hi How do i insert Account and Contact record that is coming from Web Service.

I wanted to insert both at the same time..



Hello everyone,

We have an approval process that does the following:

-We have a custom object called 'Library Requests' that is attached to Accounts with a Master-Detail relationship
-Our sales reps create a Library Request for the account they want to request (as long as the account is owned by the 'Library' user)
-They submit the Library Request for approval
-Once the Library Request is approved by their manager, a checkbox field call 'Approved' is populated (for reporting purposes)
-I then also receive an email and have to transfer the account to the requested user manually

So I tried to write a trigger that simply transfers the account to the person who created the request once the 'Approved' box is populated.

The issue? When I go to test the trigger by submitting a request for approval, I get an error message that says the following:

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger automateLibraryApproval caused an unexpected exception, contact your administrator: automateLibraryApproval: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.automateLibraryApproval: line 36, column 1".

So obviously the issue is that the Library Request is read-only, but I don't see any way to no longer make it read-only. It seems that happens by default and can't be changed.

Any idea what to do? Here is my code:

trigger automateLibraryApproval on Library_Request__c (after update) {
   
    Set<String> accountsInTrigger = New Set<String>();
   
    for(Library_Request__c lib : trigger.new){
        if(Library_Request__c.Requested_Account__c != NULL){
            accountsInTrigger.add(lib.Requested_Account__c);
        }
    }
   
    List<Account> listAccounts = [
               SELECT
                Id,
                OwnerId
               FROM
                Account
               WHERE
                Id In :accountsInTrigger
              ];
   
    Map<String,Account> mapAccounts = New Map<String,Account>();
   
    for(Account acc : listAccounts){
        mapAccounts.put(acc.Id,acc);
    }
   
    Map<String,String> mapAccountOwners = New Map<String,String>();
                                              
    for(Account acc2 : listAccounts){
        mapAccountOwners.put(acc2.Id,acc2.OwnerId);
    }
                                                
    List<Account> accountsToUpdate = New List<Account>();
   
    for(Library_Request__c req : trigger.new){
        if(req.Approved__C = TRUE && mapAccountOwners.get(req.Requested_Account__c) == '005A0000003R9p0'){
            Account libraryRequestAccount = mapAccounts.get(req.Requested_Account__c);
            libraryRequestAccount.OwnerId = req.CreatedById;
            accountsToUpdate.add(libraryRequestAccount);
        }    
    }
    update accountsToUpdate;
}



Let me know if you need any other info from me.

Thanks!
-Greg

Hi All ,

 

I have a web to lead form with Campaign_ID in it as hidden field so that we can associate that Lead with Campaign .

 

We have an After Insert trigger on Lead which Checks whether the Inserted lead is duplicate, if  it is duplicate it update the existing lead and Deletes the newly inserted Lead .

 

The problem is that I am not able to fetch Campaign_ID in my trigger from Web to lead form  to add the Campaign in Campaign history of existing Lead.

 

The Campaign Member object Doesn't have an entry for the inserted Lead till the After Insert fires so couldn't get it .

 

 

Any Help Any Click is highly Appreciated .

 

Thanks

 

 

 

 

 

 

Hi All, 

I would like to know if there is a possibility to deploy the process builder with active status in any way of deployment?. Currently I am facing the issue like is it was deployed through Ant migration tool with inactive status. So, I have to manually activate it after deployment.

Thanks in Advance!
Hi, 

I am using Tooling API for dynamic trigger on Account child level object, It is working fine in develoment environment but not working in Managed packages. 

I am really struggling why it is not working in Manged packages.

Please give me the reply if any one having idea for the same.

Thanks in advance

Muni
Can you help me on this? I have tried over and over! I get this error message on this Trailhead "Secure Your Users Identity":

Can't assign permission set Trailhead to user Sia Thripio. The user license doesn't allow the permission: Manage Two-Factor Authentication in User Interface

Any Ideas?
Hi everyone!,

I am stuck on the suerbadge challenge:
Data Integration Specialist #3 Synchronize Salesforce opportunity data with Square Peg's PMS external system

This is my code:
 
public class ProjectCalloutService {
    public static Id opportunityId;
    
    @InvocableMethod
    public static void postOpportunityToPMS(List<Id> opportunityIds){
        opportunityId=opportunityIds.get(0);
        Opportunity opp=[Select Id,Name, closeDate,amount,Account.Name FROM Opportunity Where Id =: opportunityId];
        ID jobID = System.enqueueJob(new QueueablePMSCall(opp));
    }    
    
    public class QueueablePMSCall implements Queueable,Database.AllowsCallouts
    {
        private String jsonOpp;
        private Opportunity opportunityObject;
        public QueueablePMSCall(Opportunity opp)
        {
            opportunityObject=opp;
            JSONGenerator gen = JSON.createGenerator(true);
            gen.writeStartObject();
            gen.writeStringField('opportunityId', opp.Id);
            gen.writeStringField('opportunityName', opp.Name);
            gen.writeStringField('accountName', opp.account.Name);
            gen.writeDateField('closeDate', opp.closeDate);
            gen.writeNumberField('amount', opp.amount);
            
            gen.writeEndObject();            
            
            jsonOpp= gen.getAsString();
            System.debug('jsonOpp: ' + jsonOpp);
            
        }
        public void execute(QueueableContext context) {
            
            ServiceTokens__c token= ServiceTokens__c.getValues('ProjectServiceToken');
            System.debug(token.Token__c);
            
            // create an HTTPrequest object    
            HttpRequest req = new HttpRequest();
            req.setMethod('POST');
            req.setEndpoint('callout:ProjectService/'+ token.Token__c);
            req.setHeader('Content-Type', 'application/json');
            req.setBody(jsonOpp);    
            
            // create a new HTTP object
            Http http = new Http();
            HTTPResponse res = http.send(req);
            if (res.getStatusCode() != 201) {
                System.debug('Error from ' + req.getEndpoint() + ' : ' +
                             res.getStatusCode() + ' ' + res.getStatus());
                
                Opportunity opportunity1=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity1.StageName='Resubmit Project';
                update opportunity1;
                
            }
            else {
                Opportunity opportunity2=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity2.StageName='Submitted Project';
                update opportunity2;
            }      
        }
        
    } 
}

Thanks
Hi, this is my first post on board and I ask your help (please sorry for my english).

I am French and I am 26 years old. Last March I took BSc in Computer Engineering in Paris and after few months I started an internship in one of the most important and international Consulting Company.

It took me for Salesforce team and, after a month, in June I took my first Salesforce Certification: Salesforce Platform Developer I.

I didn't know Salesforce before this job but now I love it! I love Apex code. I love to code on Force.com. I love Salesforce World and all it is around and I want improve my skills about Salesforce and I want put my future on this technology.......but there is a problem! 

Now I am not developing new code in Force.com but I am only taking hands on bug fixing, on code that other people in other country have devoloped.

I asked my boss if this situation is normal, if it is only for a period and if in the future I will develop code ex-novo but his answer was: "We are a Consultant Company, so we don't develop nothing but we only do a little change on code that other people in other countries as India and Morocco have develop. The our target is to find the customer requests".

I am very demoralized because this isn't the job that I hope for my future. 
I hoped to develop as I develloped during university so I want reason about code, which solution is best, for example, if the map collection is best than list collection etc.

In my team there are people from different degree, math, economy, computer science etc, but it isn't important if you know Java, Apex, Visualforce and other languages very well, the important is to do the correct change at code and stop!

For example, I didn't study JavaScript but now I change JavaScript code without know what and why I am doing it! 
I want study JavaScript, SOAP, REST etc to will take Salesforce Platform Developer II but I want know why I am doing this change at code and not because the important is that now the code is ok for the customer.


Maybe I don't want to understand that the world of consulting is this and it isn't as at University where the most important thing was to understand and to choose the best solution knowing all possibile ways.

This is my first job and I don't know if this is only a case or the job world is this. 
I want to develope on Force.com and I don't want job in this way. I am ready to study new languages, new Salesforce solutions, to travel in other country but the important is to find a job as developer job to improve my knowledge about this world.

Is it possible? Is possibile to develop in European countries? 

So, thanks a lot for your time and I will wait your replies.
  • June 21, 2016
  • Like
  • 0
Hi,

I want to create a button through which I will upload a image in a standard page layout.Is it possible.Please help
Hi, 
I am working on Cloning cases. I am creating a custom button because we only want few fields to get cloned. I get this error when i click on the button clone

SObject row was retrieved via SOQL without querying the requested field: Case.Status​
 
Class:

public class VFController {
 
   
    public case o {get;set;} 
   
    public VFController(ApexPages.StandardController stdController) {
        this.o = (case)stdController.getRecord();
    }
     
    // Code we will invoke on page load.
    public PageReference autoRun() {
 
        String theId = ApexPages.currentPage().getParameters().get('id');
 
        if (theId == null) {
            // Display the Visualforce page's content if no Id is passed over
            return null;
        }
 
        List<Case> cases = [Select id,lot__c,status From Case ];
            // Do all the dirty work we need the code to do
        
 
        // Redirect the user back to the original page
        PageReference pageRef = new PageReference('/' + theId);
        pageRef.setRedirect(true);
        return pageRef;
 
    }
 
}
 
VF page:
<apex:page standardController="Case" extensions="VFController">
 

    <apex:form id="frmId">
      
       <apex:pageBlock id="pb">
      
         <apex:messages ></apex:messages>
             <apex:pageBlockSection columns="1" title="Clones Case" id="pbs_Clone">
                 <apex:InputField value="{!o.status}"/>
                 
            
                 <apex:InputField value="{!o.LOT__c}" required="true"/>
                 
                 

                 
            </apex:pageBlockSection>
         <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" />
            <apex:commandButton value="Cancel" action="{!Cancel}" />
         </apex:pageBlockButtons> 
         
 </apex:pageblock>
 </apex:form>
 
 </apex:page>

 
I am not sure why I am getting this error when attempting to create this class. 

Error: Compile Error: Didn't understand relationship 'Implementation_Task__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 18 column 26
 
public with sharing class ImplementationTaskReportCtrl 
{
    public String PLAN_YEAR_ID;
    public final String SHOW_IMPTS = 'show';
    
    public List<Implementation__c__c> Implementation{get;set;}
    public List<Implementation_Task__c> ImplementationTasks{get;set;}
    
    public ImplementationTaskReportCtrl ()
    {
        PLAN_YEAR_ID = Apexpages.currentPage().getParameters().get('Id');
        if( PLAN_YEAR_ID instanceof Id  ){intialize();}
        else{Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, Label.Invalid_Id_Error ) );}
    }
    
    private void intialize()
    {
        Implementation = [ SELECT Id, Name, Total_Required_Tasks__c, Plan_Year_1__c, Percent_Complete__c, Completed_Tasks__c, 
                                                        ( SELECT Name, Completed__c, Completed_Date__c, Due_Date__c, Current_Notes__c, Historical_Notes__c FROM Implementation_Task__r WHERE In_Reports__c = :SHOW_IMPTS ORDER BY Due_Date__c ) 
                            FROM Implementation__c 
                            WHERE Plan_Year_1__c = :PLAN_YEAR_ID ];
                                                    
        if( Implementation == NULL || Implementation.isEmpty() )
        {
            Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, Label.No_Plan_Year_Related_IMPs_Error ) );
        }
        else
        {
            ImplementationTask = [ SELECT Name, Implementation__c, Completed__c, Completed_Date__c, Due_Date__c, Current_Notes__c, Historical_Notes__c FROM Implementation_Task__c 
                                        WHERE Implementation__c IN :Implementation AND ( Due_Date__c < TODAY OR Due_Date__c = THIS_WEEK ) AND Completed_Date__c = null 
                                        ORDER BY Due_Date__c ];
        }
    }
    
    public PageReference saveIMPTasksDueThisWeekAndStay ()
    {
        return save( ImplementationTask, false );
    }
    
    public PageReference saveIMPTasksDueThisWeekAndGoBack ()
    {
        return save( ImplementationTask, true );
    }
    
    public PageReference saveIMPTasksAndStay ()
    {
        List<Implementation_Task__c> IMPTasksToBeSaved = getAllIMPTasks();
        return save( IMPTasksToBeSaved, false );
    }
    
    public PageReference saveIMPTasksAndGoBack ()
    {
        List<Implementation_Task__c> IMPTasksToBeSaved = getAllIMPTasks();
        return save( IMPTasksToBeSaved, true );
    }
    
    private List<Implementation_Task__c> getAllIMPTasks ()
    {
        List<Implementation_Task__c> IMPTasksToBeSaved = new List<Implementation_Task__c>();
        for( Implementation__c aIMP : Implementation )
        {
            for( Implementation_Task__c aTask : aIMP.Implementation_Task__r )
            {
                IMPTasksToBeSaved.add( aTask );
            }
        }
        return IMPTasksToBeSaved;
    }
    
    private PageReference save ( List<Implementation_Task__c> IMPTasksToBeUpdated, Boolean goback )
    {
        try
        {
            update IMPTasksToBeUpdated;
        }
        catch ( Exception ex )
        {
            Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, ex.getMessage() ) );
            return NULL;
        }
        return ( goback ?  back () : stay() );
    }
    
    public PageReference back()
    {
        return new PageReference ( '/' + PLAN_YEAR_ID );
    }
    
    private PageReference stay()
    {
        intialize();
        return NULL;
    }


Thanks in advance!
I created a trigger to populate a checkbox on a custom object when a note is added. Now I need to add the criteria that the creator of the note is the same as a user lookup on the custom object.  I'm not sure how to get the lookup and add to the criteria.

I need the trigger to fire only when the note creator = id from the client__c lookup field on the ticket__c object.

Any help is greatly appreciated.
 
trigger NoteAI on Note (after insert) {
    
    //Collect all ParentIds into a set
    Set<Id>incIds = new Set<Id>();
    
    //List of all Incidents to be updated with the flag
    List<EscalatedTicket__c> toUpdate = new List<EscalatedTicket__c>();
    
    //Collect all ParentIds    
    for(Note n : trigger.New){
        if(n.ParentId.getSobjectType() == EscalatedTicket__c.SobjectType){
        incIds.add(n.ParentId);
        }
    }
    
    //Collect all records with the above list of parentIds and return only those records
    List<EscalatedTicket__c> TicList = [select Id, ClientUpdated__c from EscalatedTicket__c where id in:incIds];
    if(toUpdate !=null){
        for(EscalatedTicket__c inc:TicList){
            inc.ClientUpdated__c = true;
            toUpdate.add(inc);
        }
        if(toUpdate.size()>0){
        Database.update(toUpdate,false);    
        }
    
    }

}

 
  • September 23, 2015
  • Like
  • 0
Hi,

 don't know why, but the help text and the helptextimage does not appear.
<apex:pageBlockSectionItem helpText="{!$ObjectType.Opportunity.Fields.StageName.inlineHelpText}">
             <apex:outputLabel value="{!$ObjectType.Opportunity.Fields.StageName.label}" />
             <apex:inputField value="{!oppString.StageName}" />
         </apex:pageBlockSectionItem>

Thanks,
Sascha
I have a batch Apex class that makes callout in the executeBatch() method. And I need to schedule this batch to run sometime in the future. So I tried to use a Schedulable class to schedule it. But when I test, I get this error:
Callout from scheduled Apex not supported.

So I search and found a post that says to use @future. So I added that in my schedulable class. But then I get this error:
Database.executeBatch cannot be called from a batch start, batch execute, or future method.

Can someone help me find a solution? Thanks a lot. 
 
  • September 22, 2015
  • Like
  • 0
Hi, I would like to get some information or sample code about how to read an external file (ie. pdf file) which is located at AWS S3. I´ve already know there is a toolkit to do that, but I also found out that Amazon has deprecated SOAP for their services and it would be sooner or later when they decide not to support anymore new SOAP request (now for example they do it only in https calls and said they won't updgrade SOAP methods, according to their documentation).

Any help on this with some sample code would be appreciated.
Hi all,
I've tried alot of solutions for this issue but when I install the package then I received an email with exception info as below:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Please find below my code:
global class PostInstallClass implements InstallHandler {
  global void onInstall(InstallContext context) {
      User u = GetUserById(context.installerId());
      try
      {
          if(!Test.isRunningTest())          UpdatePackageInstallationInfo(context.installerId(), u.Email);
      }
      catch(Exception e)
      {
          SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + u.Email + ' tried to install/upgraed the package but failed because. Error Details: ' + e);
      }     
  }
    
    public User GetUserById(ID id)
    {
        User u = [Select Id, Email from User where Id =:id];
        return u;
    }
    
    @future(callout=true)
    public static void UpdatePackageInstallationInfo(String organizationId, String userEmail)
    {        
        String url = 'http://demoapi.sunapplabs.com/api/salesforce/updateinstallpackage?organizationid='+organizationId;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        HttpResponse responseResult = h.send(req);
        if(responseResult.getBody() == 'true')
        {            
            SendMessage(new String[]{userEmail, 'abc@xyz.com'},'Package install successful','Thanks for installing the package. Response result : '+responseResult);
        }
        else
        {
            SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + userEmail + ' tried to install/upgraed the package but failed because of failure from MyAPI response. Response result : '+responseResult);
        }
    }
    public static void SendMessage(String[] toAddresses, String subject, String message)
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('abc@xyz.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject(subject);
        mail.setPlainTextBody(message);
        Messaging.sendEmail(new Messaging.Email[] { mail }); 
    }
  }



 
Hi All,
I have one simple map like below.
Map<string,string> keyAndValues = new Map<string,string>();
keyAndValues.put('ABCD','1234');

Now i want to check whether the string 'abcd' exists in Keys of Map or not.
I ll write like this,
if(keyAndValues.containskey('abcd')){
    system.debug('Key exists in map');
}

Here It will return false as it ll check with case sensitivity.

But i want to ignore case sensitivity and want to search vth case insensivity.Is there any way to do like this.
If any one have idea please let me know.


Thanks in Advance.

Rajesh.
  • March 31, 2014
  • Like
  • 0
Hi All,

  I have List of String Values like [abc, “abcd” ,‘abcde’].
  Now i want to check all the string values and find which string contains single quotes(') and which one contains double quotes using apex.

Can any one help me how to solve this problem......


Thanks,
 Murali
  
I need help to write a test clss for below class. Please help me

public class LeadFieldUpdate
{
  public void UpdateLead(CampaignMember[] cmember)
  {
    Set<Id> leadIds = new Set<Id>();
    Set<String> campaignperLead;
    List<Lead> leadforupdate = new List<Lead>();
    String Compname;
   
   
    for (CampaignMember  cm: cmember)
    {
       leadIds.add(cm.LeadId);
      
    }
    for(Lead con:[SELECT id, Cname__c,(SELECT id, CampaignId, CreatedDate,Campaign.Name, Campaign.StartDate, Status, LeadId, HasResponded FROM CampaignMembers Order by CreatedDate,HasResponded) FROM Lead where Id IN :leadIds])
    {
      Compname = NULL;
     
      campaignperLead = new Set<String>();
      for(CampaignMember uis: con.CampaignMembers)
      {
        IF(uis.CampaignId!= NULL && uis.HasResponded == true)
        {
          Compname = uis.CampaignId;
         
        }
      }
      boolean isUpdateRequired = false;
    
      if(con.Cname__c != string.valueof(Compname))
      {
       
        con.Cname__c = string.valueof(Compname);
        isUpdateRequired = true;
        system.debug('6----******Lead Updated Compaign Name is*********' + con.Cname__c);
       
      }
      if(isUpdateRequired)
        leadforupdate.add(con);
       
    }
     if(leadforupdate.size() > 0)
            update leadforupdate; 
  }
}

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.