• Rahul.Mishra
  • SMARTIE
  • 997 Points
  • Member since 2017
  • Sr. Salesforce Developer
  • IBM


  • Chatter
    Feed
  • 29
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 158
    Replies

Hey everyone,

I'm trying to write a trigger where if any of the follwing checkboxes are checked off:

Active_1__c 
Active_2__c 
Active_3__c
Active_4__c 
Active_5__c 
Active_6__c 

It marks a separate checkboxed called 

Active_main__c

and if all the checkboxes are unchecked, so is Active_main__c.

 

Can someone help with this? I'm new to the developer space.

I guess this is a full on newbie question, but I'm working on the Challenge  Developer Beginner  > Apex Basics & Database > Write SOQL Queries... the unit shows sample queries like  "SELECT FirstName,LastName FROM Contact" which work fine when I execute. My question is: when I look at the Contact Object/entity/table, it does not list these fields (see screenshot below). Can someone steer me in/explain why the query works when I don't see these fields/columns!?   LMK - thanks! 

Here is a search Field names like "Last" - I don't see LastName?! 

Screenshot of Field Names for the Contact Object - no LastName listed
Hi,

I am trying to update contact's phone by querying the account , But it gives me following error

"A non foreign key field cannot be referenced in a path expression: Contacts"

try
{
    Account a=[select name,(select name from contacts ) from account];
    a.name='Dialog';
    a.contacts.phone=123;
    
    update a;
    update a.Contacts;
}
catch(DmlException e)
{
    System.debug(e.getMessage());
}
I have written this trigger :-

    CustmSettOnTrig_Camp__c obj=CustmSettOnTrig_Camp__c.getInstance();
    
     if(obj.isActive__c==true ){                         //Bold lines denote the custom setting provided by me and i want this line should be tested in the                                                                                     test class
        
         Set<id> accId =new Set<id>();
         list<Account> listAccToUp =new list<Account>();
        if(Trigger.isInsert ||Trigger.isUpdate){
//some code.. }

And i have written test class for that is :-



@istest public class TestClass_ForTrig_OnCamp {
    @istest public static void createCampaign(){
             
        CustmSettOnTrig_Camp__c obj=CustmSettOnTrig_Camp__c.getInstance();
        obj.isActive__c=true; //Something wrong here if i commit the custom setting in trigger the code coverage is 70% and if i didnt commit that                                                          code then the code covergae is 8%
      //some code  
      

 
Hi All,

I want to create rollup summary fields on Account object.
Scenario : calculate how many open opportunities (except closed won,closed lost) and populate on account record.

please find the below code
trigger CalculatingOpenOpportunity on Opportunity (After insert) 
{
     if(Trigger.isInsert && Trigger.isAfter)
      {
          Set<id> accountids = new Set<id>();
          List<Account> acclist = new List<Account>();
          for(Opportunity opp : trigger.new)
          {
             if(opp.StageName != 'Closed Won' && opp.StageName != 'Closed Lost')
             {
                 accountids.add(opp.id);
                 system.debug('values in the accountids:========================================>'+accountids);
             }
          }
          
          // get a map of the accounts 
         Map<id,Account> accountMap = new Map<id,Account>([select id,Open_opportunities_count__c from Account where id IN :accountids]);
         System.debug('values in the accountMap :=============================================>'+accountMap);
        //Quering related opportunities and accounts.
        for(Account acc:[select id,name,Open_opportunities_count__c,(select id,name,StageName from opportunities) from Account where ID IN :accountids])
        {
             accountMap.get(acc.Id).Open_opportunities_count__c = acc.Opportunities.size();
             System.debug('values in the accountMap.get(acc.Id).Open_opportunities_count__c:================================>'+accountMap.get(acc.Id).Open_opportunities_count__c);
             //Adding count and opportunities to list
             acclist.add(accountMap.get(acc.Id));
        }
        
        if(acclist.size() > 0)
         {
           System.debug('Size of the acclist :==============================>'+acclist.size());
           database.update(acclist);
         }
      }
}

Please help on above scenario's
I am trying to add the Due Date to an Activity report, but can't find the Due Date listed as a field I can add. Does anyone know if that might go by another name in reporting on Activities? I see Due Time but not Due Date. It shows up on the Open Activites section of the Contact record, but isn't available as a field in reporting. 

Thanks in advance for any help. 
Hello, I am fairly new to developing in Salesforce and am trying to create a form for a custom object and insert the information into the system. I have the form and custom controller created but it will not insert the newly created record into the database. I get the error "attempt to de-reference a null object". Any help would be appreciated.

Visualforce Page

Apex Class

Actual Page
hi, 
I'm working on the below link trailhead. 
https://trailhead.salesforce.com/modules/lex_dev_lc_vf_concepts/units/lex_dev_lc_vf_concepts_basics

I'm not able to understand what's needs to be done on the step 2. 

1.Create a new Lightning component named myEverythingComponent
2. Add this static text to the component: I'll have one with everything
3. Add each resource type to the component, by clicking Create for each resource type: Controller, Helper, Style, Documentation, Renderer, Design, SVG

can someone please assist me on this? 
Hello everyone, I've created a VF form through the case object, from which, a technician will fill out the form based on customer input in reagrds to the product service issues. I've created two picklist fields for states and managers represeting those states. Whenever, the technician selects a state , I want the manager field to be auto assigned. How do I do that on the VF form? I don't want the technican to select the manager, I want it that to be auto populated based on the selected state.
Hi everyone, I'm a complete newbie to Apex and I'm recently writing an email template that sends out all of the opportunities related to a specific account name. However I don't fully understand what <apex:repeat> does.

In <apex:repeat var="op" value="{!relatedTo.Name}">, what does "var" refer to and what does "value" refer to? Does this create a loop that iterates through all of the records in relatedTo that have Name equal to value? 

Please help me with this! Thank you so much!
 

Hi All,I have 4 fields.(2 checkbox fields and 2 text fields)
Checkbox field name: Account_checkbox__c
                                   Contact_checkbox__c
Text Fields: Lenght__c
                   Salary__c
             
The scenario will be like this.

Lenght__c (Text) == 10000(containing some data)
Salary__c(Text) == null(doesn't contain any data){if this contains any data don't throw the validation}
Account_checkbox__c = true (or) Contact_checkbox__c = true {any one of the field checkbox makes to true, throw validation}
then fire the validation.

Could you please help me out how to figure that out.

 

Hi All,

I am looking for some help in writing a trigger that upon Opportunity creation (either from lead conversion or later) will get the contact ID from contact role and match that with the contact ID in the custom object to get Opportunity ID and update the custom object with opportunity fields.

Thanks!
 
Whenever I open resources for some of the lightning components I am using the code is not there and it just says (hidden) what would be causing this?
Hi Team,

I have one question, how can i convince the client to migrate from salesforce classic to salesforce lightning. I searched a lot but I am getting regular points only like UI, responsive nature, reducing the server calls. But my team is asking me beyond this points. Can anyone please brief me in full technical terms. Why we are going for lightning?
Please help me on this.. Thanks in advance…

Thanks
Venkat.
Hi All,

Please help me to write test calss for below trigger.Also it will be helpful if you add basic information as comments for understanding.

trigger UpdateTicketDetails on Ticket_Details__c (before insert,before update) {

    if(Trigger.isInsert){
    
        Id ticketRecordType = Schema.SObjectType.Ticket_Details__c.getRecordTypeInfosByName().get('Service').getRecordTypeId();
      //list<Ticket_Details__c> ticketList = new list<Ticket_Details__c> ();
        for(Ticket_Details__c ticket:Trigger.new){        
            if(ticket.recordTypeId==ticketRecordType){            
                ticket.Incident__c=False;
                ticket.Ticket_Description__c='Ticket is Service Request';
            }else{            
             ticket.Incident__c=True;
             ticket.Ticket_Description__c='Ticket is Incident';    
            }            
            //ticketList.add(ticket);
        }
       // insert ticketList;
    }
    
    if(Trigger.isUpdate){      
       for(Ticket_Details__c ticket:Trigger.new){
            String oldStatus= Trigger.oldMap.get(ticket.Id).Ticket_status__c;
            
          If(ticket.Ticket_status__c!=oldStatus){
              system.debug('Status has been changed');
              ticket.Ticket_Summary__c='Status changed from ' + oldStatus +' to '+ ticket.Ticket_status__c+'.';
          }        
       }       
    }
}
Hi,

I am trying to create new user for my developer org. But, in the profile only following options are visible as shown in Figure. If I select any one for creating a new user and tried to log in with new credientials. The default salesforce apps i.e. sales, marketing, service are not visible and also I cannot access developer console and visualforce pages which I created by login with different user. Please help me what changes should I made. 

User-added image
This is the trigger :
Trigger CreatingAutoRecords on OrderItem(After Insert, After Update)
{
    
    List<Screens__c> ScreensRecordsFinalListToInsert = New List<Screens__c>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate)
    {
        For(OrderItem con : Trigger.New)
        {
            If(con.Quantity != null)
            {
                List<Screens__c> fetchingAlreadyExixtsedRecords = [Select Id FROM Screens__c WHERE  Order_Product__c =:con.Id];
                
                If(fetchingAlreadyExixtsedRecords.IsEmpty())
                {
                    // We are only creating a records when there is no Screen Record records exixts.
                    For(Integer I = 0; I < con.Quantity; I++)
                    {
                        Screens__c crd = New Screens__c();
                        
                        crd.Order_Product__c = con.Id;
                          crd.Name = 'Screen';
                          crd.Account__c = con.Account__c;
                   
                        ScreensRecordsFinalListToInsert.add(crd);
                    }
                    
                   
                }
                
            }
            
            try{
                If(!ScreensRecordsFinalListToInsert.IsEmpty()){
                    insert ScreensRecordsFinalListToInsert;
                }
            }
            Catch(Exception e){
                System.debug('The thrown exception for CreatingAutoRecords is:: ' + e.getMessage());
            }
        }
    }
    }

This is the test class:
@isTest

private class CreateAutoRecordsTest {
    @istest
    private static void insertRecord()


{




List<Screens__c> ScreensRecordsFinalListToInsert = New List<Screens__c>();

    
                   
                 Screens__c crd = New Screens__c();
                        
                          crd.Name = 'Screen';
                          
                           ScreensRecordsFinalListToInsert.add(crd);
                          
                            insert ScreensRecordsFinalListToInsert;
   
   } 
   }


I deploy them together. Then I run try to validate in production and I keep getting a code coverage error. 

 
How can i retrieve account records in which zero contacts available ?

Please reply, how can i achieve this?

Thanks in advance.
Hi Guys,

I have created a site /community, there I am using standard pulisher and feed component, there I see case milestone in feed, on click of that I navigate to Case Milestone detail page, details not visible , says acess issue, infact I tried with admin user also, same case with admin too, admin can acess case milestone in salesforce.

User-added image

On click of that link-


User-added imagePlease let me know,if anyone knows.

Thanks,
Rahul

 
Hi, 

Can any one help me here:
I have a workflow rule on Case which sends email to following people from Email Template:
User-added image


When account team does not present then workflow does not send email but it always allows to create Case.
My work is to consolidate it to PB, I have created PB with same condition and selected the Same email alert to send the email.
Now the problem is when Account team is not present, I get the flow error while saving the record it self, also email with exception : 0 recipients.
Also I am not able to do null check of Account team from process builder, unable to get them in formula.
Can anyone help me out on the same, how to achieve it, either by process builder or process flow.

​Thanks in advance
Hi,
Can anyone please help me here:
User-added image

My task is to remove this workflow and create the process builder with same condition. Problem here is with Owner, Case Owner Can be a user or Queue, in workflow condition we are checking the Case owner's name but we have to check this only when owner is Queue.
I have tried to implement this using following way:
 
AND(ISPICKVAL([Case].Status , 'Open') ,[Case].CaseRecordTypeName__c = 'Global Lead Management Intake' ,IF(BEGINS([Case].OwnerId, '00G')  ,IF([Case].Owner:Queue.DeveloperName <> 'GBL_Case_Management_Queue', True, False) , True) )

But it did not worked for me, can anyone please help me to get the exact formula.

Thanks,
Rahul
 
Hi,

In one of my project, we are accesing a report from link or URL on record detail in salesforce classic, that link does not open the same report in lightning because instance URL gets change. I thought of replacing the instance URL with lightning instance URL so that it will be open in lightning, but it did not worked for me.

When I looked at the report URL: https://rahulmishratraning-dev-ed.my.salesforce.com/00O?rt=47, I notice that ID is not specified for report and still it opens 'Account Owner Report', also we do not have any such report in org. To verify it, I tried to open it: instance_url/00O?rt=47 in my dev org and it also opens up 'Account Owner Report' which was not created by me and not able to search from list of report.

I am not sure what rt=47 denotes here, and how it shows the report which was not created. What I have to do if I have to open the same report in Lightning.

Please help me on that, thanks in advance!

Hey everyone,

I'm trying to write a trigger where if any of the follwing checkboxes are checked off:

Active_1__c 
Active_2__c 
Active_3__c
Active_4__c 
Active_5__c 
Active_6__c 

It marks a separate checkboxed called 

Active_main__c

and if all the checkboxes are unchecked, so is Active_main__c.

 

Can someone help with this? I'm new to the developer space.

Hi All,
I need help in writing test class for trigger. I have written but its giving only 65%. Please help me.
trigger test1 on obj1__c (after insert, after update)
{
if(trigger.isAfter&& (trigger.isinsert || trigger.isUpdate))
{
    test3.method1(Trigger.New);
}
}
 
public class test3
{
    public static void method1(List<Obj1__c> o1)
    {
        map<string, obj1__c> ObjMap = new map<string, obj1__c>();
    
    for(obj1__c obj: o1)
    {
        if (obj.Shared_Field__c != Null)
        {
            ObjMap.put(obj.Shared_Field__c, obj);
        }
    }
    
    List<obj2__c> obj2l = [SELECT Id, Shared_Field__c, F1__c,f2__c 
                        FROM obj2__c WHERE Shared_Field__c IN :ObjMap.KeySet()];
    List<obj2__c> obj2list = new List<obj2__c>();
    
    for(obj2__c c: obj2l)
    {
        obj1__c obj = ObjMap.get(c.Shared_Field__c);
        c.f1__c = obj.f1__c;
        c.f2__c = obj.f2__c;
        
        obj2list.add(c);
    }
    
    if(obj2list.size() > 0)
    {
        update obj2list;
    }
    }
    
}

Thanks in Advance

 
Hi 
I am new in this field and still learning; I tried to add the below to display some information from my product in the T&Cs
but it returns the following error Error: Unknown property 'OpportunityStandardController.Contract'​

 <apex:repeat value="{!Contract.Opportunity_Product__r}" var="line">
            <tr>      
                <td>{!line.Product2.Name}</td>
                <apex:outputText rendered="{!If(line.Product2.Early_Termination_Clause__c!=Null,True,False)}">
                    <td style="text-align:center">{!line.Product2.Early_Termination_Clause__c}</td>
                </apex:outputText>  
                <apex:outputText rendered="{!If(line.Product2.Early_Termination_Clause__c==Null,True,False)}">
                    <td style="text-align:center">No Clause Available</td>
                </apex:outputText>  
            </tr>
        </apex:repeat>


This is my trigger I have write to add a specific account ID to a Contact. I am new to salesforce programming and I try to write the unit test but I need some help to do it.
trigger Contacts_Accounts on Contact (Before Insert, Before Update) {

for (Contact newContact : Trigger.New){
        String id_account;
        id_account = [select id from Account where idClientSoquij__c = :newContact.idClientSoquij__c].id;
        newContact.AccountId = id_account;
        }
}

 
i had gone through developer guide and other things, i need the a small example what really the metadata is with an example , of simple 
thanks and regards
Hi,
The user is currently able to edit the Probability Percentage for each stage of the Opportunity. The system should not allow the user to Save the changes made to the Probability field. I did write a validation rule, but it is not working. could you please post answer asap.


 
Hi all,

I have a custom object called "CO" and having a field called "User".
I am able to get Account ID now, but I would like to get Account Name insted.
Would someone let me know if there is a way to get Account Name from CO?

=================================
CO (CO__c)
----
Id
User (User__c) -> Contact
                            ---------
                            Id
                            Company  (Account) -> Account
                                                               ---------
                                                               Id
                                                               Name
=================================

"User"       : Lookup(Contact)
"Company": Lookup (Account)

This is what I have now.
select User__r.AccountId from CO__c where Id = 'xxxxxxx';

Thank you,
HG
  • July 10, 2018
  • Like
  • 0
I just want to delete the opportunityshare record as below code. but when I delete it , it give me the error message as the title shows.(System.DmlException: Delete failed. First exception on row 0 with id 00t0U00000RD77SQAT; first error: INVALID_CROSS_REFERENCE_KEY, id does not exist: []). and I checked the result from database , I found the record has been deleted but new record inserted into the database(new record is the same to the old one except the record id).
Anyone who has ever met this kind error before? I would appreciate if anyone can help me . Really thanks a lot.


List<OpportunityShare> oppShareListDel = [SELECT id from OpportunityShare where OpportunityId in: oppIdListForShareDel and Rowcause = 'Manual' and userorgroupid in: oppUserOrGroupIdListAll];
 try{
          delete oppShareListDel;
 }catch(Exception excep){
          System.debug('error aaa:::  '+excep);
  }                   
I guess this is a full on newbie question, but I'm working on the Challenge  Developer Beginner  > Apex Basics & Database > Write SOQL Queries... the unit shows sample queries like  "SELECT FirstName,LastName FROM Contact" which work fine when I execute. My question is: when I look at the Contact Object/entity/table, it does not list these fields (see screenshot below). Can someone steer me in/explain why the query works when I don't see these fields/columns!?   LMK - thanks! 

Here is a search Field names like "Last" - I don't see LastName?! 

Screenshot of Field Names for the Contact Object - no LastName listed
While creating a approval process in trail head , this is the error I was getting :  The final approval is not configured correctly for 'Discount Approval Process'. Approving the opportunity did set the opportunity's Approval_Status__c field value to 'Approved'.  Please can any one help in understanding why.
Hi,

I am trying to update contact's phone by querying the account , But it gives me following error

"A non foreign key field cannot be referenced in a path expression: Contacts"

try
{
    Account a=[select name,(select name from contacts ) from account];
    a.name='Dialog';
    a.contacts.phone=123;
    
    update a;
    update a.Contacts;
}
catch(DmlException e)
{
    System.debug(e.getMessage());
}
this is my helper class:-
public class CaseTriggerHelper {
    public static List<Case> newCases = new List<Case>();
    public static List<Case> oldCases = new List<Case>();
    public static Map<Id, Case> newMapCases = new Map<Id, Case>();
    public static Map<Id, Case> oldMapCases = new Map<Id, Case>(); 
    
    public static void firstResponce(){
        
        BusinessHours defaultBH = [ SELECT Id 
                                    FROM BusinessHours 
                                    WHERE IsDefault = true  Limit : 1
                                  ];
        
       
        for(Case caseObj : newCases ){
           
            if( (caseObj.First_Response__c == Null)
                && UserInfo.getUserId() == caseObj.OwnerId ){
                     
                    Decimal result = BusinessHours.diff(defaultBH.Id, caseObj.CreatedDate, caseObj.LastModifiedDate );
                    
                    Decimal resultingHours = result/(60*60*1000);
                    caseObj.Helper_First_Responce__c= resultingHours;
                      
                    Decimal HH = resultingHours.round(System.RoundingMode.DOWN);
                   
                    Decimal tempMM = ( resultingHours - resultingHours.round(System.RoundingMode.DOWN))  * 60;
                    Decimal MM = tempMM.round(System.roundingMode.DOWN);
                    
                    Decimal SS = (( tempMM - tempMM.round(System.RoundingMode.DOWN)) * 60).round(System.roundingMode.DOWN);
                     
                    string finaltime = ''+HH+':'+MM+':'+SS;
                    caseObj.First_Response__c=finaltime;
                     
               } 
                     
        } 
         
    }    now i have a requirement to populate the time between when case is opned and its first responce in the field First_Response__c in HH:MM:SS .now the issue is when i create a new case it shows 0:0:0 in First_Response__c rather than showing some time in the field
like some seconds like0:0:12 .
how i fix this issue?
any suggestions?