• Prashant Pandey07
  • NEWBIE
  • 285 Points
  • Member since 2015
  • Salesforce Developer

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 77
    Replies

Hi Everyone,

I've created a simpletrigger that creates a new record of custom object: Hosted_PBX_Deployment__c when a new Opportunity is created.
Now I need to set a value to a fiield: Rack_4_19_two_post_Qty__c in custom object that depends on a value of an Account field: All_Network_Devices_Qty__c
so if Account.All_Network_Devices_Qty__c <=11 then Rack_4_19_two_post_Qty__c =1 

what is the best way to reffer to an Account field from Hosted_PBX_Deployment__c trigger?

this is my trigger:

trigger AutoCreateHPBXdeployment on Opportunity (after insert) {


List<Hosted_PBX_Deployment__c> newHPBX = new List<Hosted_PBX_Deployment__c>();
  for (Opportunity opp : Trigger.new) {
      if(opp.Hosted_PBX__c=='Yes'){
    Hosted_PBX_Deployment__c hpbx = new Hosted_PBX_Deployment__c();
    hpbx.Opportunity__c  = opp.Id;
    hpbx.Opportunity_Account__c = opp.AccountId;
   
 
    newHPBX.add(hpbx);
      }
  }
  insert newHPBX;

}

Thank you!

There are two inputText Mobile and Email.
When i fill only Mobile inputText one popup message should be display and if i fill only email inputText another popup messege should display.
I have a visualforce page that I used to override the 'New Opportunity' button on the Opportunity related list on the Account. To make this usable in Lightning, should I create a lightning component? Or is there a way to use the Visualforce page that I already have written? 

Any advice is greatly appreciated. 

Thanks, 
Tasia
Hi there,

I have two custom objects. The Investigation__c is the parent object, and the Time_Entry_Recap_Report__c is the child object. What I want to have happen is when the parent record (Investigation) is initially created, I want to create an initial entry in the 'Time_Entry_Recap_Report__c' with 15 minutes of time worked and a description of the task being 'Opened new investigation'. I'm trying to figure out how to relate the Child record to the parent record when I create the entry in the trigger. The object 'Time_Entry_Recap_Report__c' is already defined as a child to the parent, but trying to insert the record without a reference to the 'Investigation_Time_Entry__c' field within the 'Time_Entry_Recap_Report__c' object didn't work either. The Error I am getting is "Error: Compile Error: Illegal assignment from Schema.SObjectField to Id at line 8 column 7. Any assistance would be greatly appreicated. 
trigger CreateTimeEntry on Investigation__c (after insert) {
    List<Time_Entry_Recap_Report__c> entryList = new List<Time_Entry_Recap_Report__c>();
    for(Investigation__c InvestigationObj : Trigger.new){
    Time_Entry_Recap_Report__c entry = new Time_Entry_Recap_Report__c();
      entry.Hours_Worked__c = '00';
      entry.Minutes_Worked__c = '15';
      entry.Work_Performed__c = 'Opened new investigation';
      entry.Investigation_Time_Entry__c = Investigation__c.NAME;
      entryList.add(entry);
     }
     if(entryList.size()>0){
      upsert entryList;
     }
}

 

how to achive this requirment? can anybody pls help.. 

Account: location(pick list custom field),if location is delhi add user_X as accountTeam member, bnglr add  user_Y as accountTeam member, 
chennai add user_Z as accountTeam member
other add K as accountTeam member...
Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
Hello everyone,

I need to convert this trigger into a class and them call it in a trigger in another object.
Can someone help me?

Also, I created 3 lists for validation of the records in this object, I know that is not the best way of doing, so what is the bets of way?
this 3 lists:cont_social, cont_loca, rg_cpf
 
trigger Unidade_Status on Campus__c (before update) {
    
    for (Campus__C a :trigger.new) {
        
        list <Integrante_equipe__c> integrantes = new list<Integrante_equipe__c>();
        integrantes = [SELECT ID FROM INTEGRANTE_EQUIPE__c WHERE INTEGRANTE_EQUIPE__c.POLO__C = :a.Id AND
                       integrante_equipe__c.funcao__C = 'Sócio' AND
                       integrante_equipe__c.cpf__C != null];
        
        list <Documentos_Parceiro__c> cont_social = new list <Documentos_Parceiro__c>();
        cont_social = [SELECT ID
                       FROM Documentos_Parceiro__c
                       WHERE Documentos_Parceiro__c.Unidade__c =: a.Id
                       AND Recordtype.name = 'Contrato Social'];
        
        list <Documentos_Parceiro__c> cont_loca = new list <Documentos_Parceiro__c>();
        cont_loca = [SELECT ID
                     FROM Documentos_Parceiro__c
                     WHERE Documentos_Parceiro__c.Unidade__c =: a.Id
                     AND Recordtype.name = 'Contrato de Locação'];
        
        list <Documentos_Parceiro__c> rg_cpf = new list <Documentos_Parceiro__c>();
        rg_cpf = [SELECT ID
                  FROM Documentos_Parceiro__c
                  WHERE Documentos_Parceiro__c.Unidade__c =: a.Id
                  AND Recordtype.name = 'RG/CPF Sócios'];
        

        if(a.City__C != null &&
           a.State__C != null &&
           a.Email__c != null &&
           a.Work_Phone__c != null) {
               
               if(a.LastActivityDate != null) {
                   
                   if(a.CNPJ__c != null &&
                      a.Razao_social_c__C != null &&
                      a.Street_Address__c != null &&
                      a.House_Number__c != null &&
                      a.Bairro__c != null &&
                      a.Zip_Code__c != null ) {
                          
                          if (!integrantes.isEmpty()) {
                              
                              if(cont_social.size() > 0 &&
                                 cont_loca.size() > 0 &&
                                 rg_cpf.size() > 0){
                                     
                                     a.Status_parceria__c = 'Em Análise';
                                 }
                              
                              Else {
                                  
                                  a.Status_parceria__c = 'Pré-Cadastro'; 
                              }
                          }
                          
                          Else {
                              a.Status_parceria__c = 'Pré-Cadastro';
                          }
                      }
                   Else {
                       a.Status_parceria__c = 'Negociação';
                   }
               }
               Else {
                   a.Status_parceria__c = 'Lead';
               }
               
           }
        Else {
            a.Status_parceria__c ='';
        }
    }
}

 

Hi Everyone,

I've created a simpletrigger that creates a new record of custom object: Hosted_PBX_Deployment__c when a new Opportunity is created.
Now I need to set a value to a fiield: Rack_4_19_two_post_Qty__c in custom object that depends on a value of an Account field: All_Network_Devices_Qty__c
so if Account.All_Network_Devices_Qty__c <=11 then Rack_4_19_two_post_Qty__c =1 

what is the best way to reffer to an Account field from Hosted_PBX_Deployment__c trigger?

this is my trigger:

trigger AutoCreateHPBXdeployment on Opportunity (after insert) {


List<Hosted_PBX_Deployment__c> newHPBX = new List<Hosted_PBX_Deployment__c>();
  for (Opportunity opp : Trigger.new) {
      if(opp.Hosted_PBX__c=='Yes'){
    Hosted_PBX_Deployment__c hpbx = new Hosted_PBX_Deployment__c();
    hpbx.Opportunity__c  = opp.Id;
    hpbx.Opportunity_Account__c = opp.AccountId;
   
 
    newHPBX.add(hpbx);
      }
  }
  insert newHPBX;

}

Thank you!

Is there a simple way, in the controller for a Lightning component, to get the My Domain of the org? I would like to easily know the URL for login of the org this component is displaying in so that I could know mydomain.my.salesforce.com or mydomain.lightning.force.com.

Literally all I'm looking for is the method to get the string "mydomain"
HI All,

i have written the below trigger on the ContentDocument object for a Before Insert scenerio, but the trigger seems not to be firing.
Can anyone help me with this, below is my code

Trigger
trigger ContentDocumentTrigger on ContentDocument (Before Insert) {
    if(trigger.isInsert && trigger.isBefore){
        fileSharing.publicGroupOwnership1(trigger.new);
    }
}

Handler class
public without sharing class fileSharing{
    
    public static void publicGroupOwnership1 (list<ContentDocument> ContentDocumentRcd){
        
        profile adminProfile = [Select id from profile where name='System Administrator'];        
        user adminUser = [Select id, name from user where profileId=:adminProfile.id];
        
        for(ContentDocument ContentDocumentLoop :ContentDocumentRcd){
            
            ContentDocumentLoop.OwnerId = adminUser.Id;
        }
        system.debug('$$contentDocumentRcd '+contentDocumentRcd);
    }
}
Hi All, 
 their is one requirement i have ..
i have 'Amount field' on opportunity needs to be entered whenever a opportunity is created related to a particular account  once a opportunity is created ,then i want 'Total Opportunity Amount' field on Account object needs to be updated.

I want to write trigger for the same

How it will be done

I have written this much amount of code, but i am not able to go ahead..as i am on learning stage ..please help me out.

public class opportunityhandler
{
 public void opportunityamount(list<opportunity> newopportunity)
 {
  set<String> setOppName=new set<String>();
  for(opportunity opp:newopportunity)
  {
    setOppname.add(opp.Amount);
  }
    list<opportunity> opps= [select Name, Amount from opportunity where AccountId =:setOppname];
    {
    
    }
  }
 }
 
There are two inputText Mobile and Email.
When i fill only Mobile inputText one popup message should be display and if i fill only email inputText another popup messege should display.
How to redirect previous visualforce page from current visualforce page?

Hi Everyone,

 First of all here i'm having two visualforce pages
 
 1.Webinar_Details Page
 2.MappingLeadPage
 
 webinar_details page is a record details page it displays all the details of one particular record.
 In this page i'm having a button calles "Mapping Lead" by clicking the button it redirects to the
 "MappingLeadPage" visualforce page.after mapping the fields i'm saving the mapping and redirects to the previous record
 details page.
 
 here for redirecting i need the previous record id.how can i get the previous record id for redirecting
 
 Webinar_Details Page
 --------------------
 <apex:page standardController="Webinar__c" tabstyle="Adobe_Webinars__tab" sidebar="false" extensions="RedirectPage">
    
    <apex:form >   
     <apex:pageBlock title="Adobe Connect Integration with Salesforce">
         <center>         
           <apex:commandButton value="Register" action="{!doRegistrationForm}"/>     
         </center><br/><br/>
         <apex:pageBlockSection title="{!Webinar__c.Name} Details">
            <apex:outputField value="{!Webinar__c.Name}"/>      
            <apex:inlineEditSupport event="ondblClick" /><br/>                    
         </apex:pageBlockSection><br/>         
    </apex:pageBlock>           
          <apex:pageBlock >
            <apex:pageBlockTable value="{!wrapperAccountList}" var="w" id="table" title="All Accounts">
                 <apex:column value="{!w.acc.Login__c}"></apex:column>
                 <apex:inlineEditSupport event="ondblClick" />
                 <apex:column value="{!w.acc.isLead__c}"></apex:column>                                
            </apex:pageBlockTable>
        </apex:pageBlock>
               
         <center>
              <apex:commandButton id="leadcreate1" value="Lead Mapping" action="{!doMappingPage}"/>
          </center><br/>   
    </apex:pageBlock>      
 </apex:form>         
</apex:page>

extension:
-----------

 public class RedirectPage{
 
        public PageReference doMappingPage(){            
        PageReference parentPage = new PageReference('/apex/MappingLeadPage');
        parentPage.setRedirect(true);
        return parentPage;
  }
 
}

MappingLeadPage
----------------
<apex:page standardController="Lead" extensions="MappingLead1">    
  <apex:form >  
    <apex:pageBlock title="Lead Mapping" >             
      <apex:pageBlockSection >       
        <apex:pageBlock >            
           <apex:pageBlockSection >          
                   Webinar Attendee Name  <apex:inputField value="{!Lead.LeadFields__c}"/><br/>  
                   Webinar Attendee Email <apex:inputField value="{!Lead.Lead_Fields1__c}"/><br/>
                   Webinar Attendee Company  <apex:inputField value="{!Lead.Lead_Fields2__c}"/><br/>  
               Webinar Attende Mobile Number <apex:inputField value="{!Lead.Lead_Fields7__c}"/><br/><br/>
                  <!--   <apex:outputLink value="{!URLFOR($Page.Webinar_Details,w.acc.Id,[id=w.acc.Id])}">{!w.acc.name}</apex:outputLink>    -->         
            
         </apex:pageBlockSection>
            <apex:commandButton id="saveBtn" value="Save Mapping" action="{!processButtonClick}" style="margin-left:-2%"/>                                          
               <apex:commandButton id="saveBtn1" value="Previous Page" action="{!goBack}" style="margin-left:30%"/>                                          
            <apex:pageBlockButtons >
            </apex:pageBlockButtons>
       </apex:pageBlock>   
     </apex:pageBlockSection>     
   </apex:pageBlock>                
  </apex:form>
</apex:page>


extension
------------
public with sharing class MappingLead1  {
    public Lead login;
    private final ApexPages.StandardController controller;                  
    public MappingLead1(ApexPages.StandardController controller){       
        this.login= (Lead)controller.getRecord();  
    }

    public PageReference goBack(){
    PageReference pg = new PageReference('/apex/Webinar_Details');
    pg.setRedirect(true);
    return pg;
  }
}

from the MappingLeadPage page by clicking the "Previous Page" button how i redirected to the Webinar_Details Page vf page.

Please anybody help i'm trying this logic from yesterday

Thanks In Advance

 
public class UpdateUser {
    Public static void method1(List<case> caseList){
        set<id> parentcaseId = new set<Id>();
        for(case cs:caseList){
            if(cs.Defect__c != null){
                parentcaseId.add(cs.Defect__c);
            }
        }
        
        List<Case> caseslistold = [SELECT Id, OwnerId FROM Case WHERE Id in : parentcaseId];
        for(Id csIdtoUpdate:parentcaseId){
            for(Case cas:caseslistold){
                for(case cs:caseList){
                    cs.Product_Lead__c=cas.ownerId;
                }
            }
        }
    }
}
 
trigger updateUsertrig on Case (before insert, before Update) {
    if((trigger.isInsert && trigger.isBefore) || (trigger.isUpdate && trigger.isBefore))
UpdateUser.method1(trigger.new);
}

 
Hi All,

I have Account object and Issue(custom object). Issue object have look up relation with Account. I have a button called create Issue on Account object which is overriden by VF page. When I click on create Issue, i want to render some fields based on associated account region. so in my controller i want to check something like below.
If(Issue__c.Account__r.Region__c == 'abc') is this the correct way? I am getting the expected value. Can some one please help me with this pls?

Thanks.
  • February 02, 2018
  • Like
  • 0
Hi there,

I have two custom objects. The Investigation__c is the parent object, and the Time_Entry_Recap_Report__c is the child object. What I want to have happen is when the parent record (Investigation) is initially created, I want to create an initial entry in the 'Time_Entry_Recap_Report__c' with 15 minutes of time worked and a description of the task being 'Opened new investigation'. I'm trying to figure out how to relate the Child record to the parent record when I create the entry in the trigger. The object 'Time_Entry_Recap_Report__c' is already defined as a child to the parent, but trying to insert the record without a reference to the 'Investigation_Time_Entry__c' field within the 'Time_Entry_Recap_Report__c' object didn't work either. The Error I am getting is "Error: Compile Error: Illegal assignment from Schema.SObjectField to Id at line 8 column 7. Any assistance would be greatly appreicated. 
trigger CreateTimeEntry on Investigation__c (after insert) {
    List<Time_Entry_Recap_Report__c> entryList = new List<Time_Entry_Recap_Report__c>();
    for(Investigation__c InvestigationObj : Trigger.new){
    Time_Entry_Recap_Report__c entry = new Time_Entry_Recap_Report__c();
      entry.Hours_Worked__c = '00';
      entry.Minutes_Worked__c = '15';
      entry.Work_Performed__c = 'Opened new investigation';
      entry.Investigation_Time_Entry__c = Investigation__c.NAME;
      entryList.add(entry);
     }
     if(entryList.size()>0){
      upsert entryList;
     }
}