• smitha vikram
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 6
    Replies
I havea requirement where  I have to update a contacts custom rich text area when a picklist value changes in Opportunity.
The trick is when the picklist changes on Opp, there are three values from opportunity for ex A,B & C should be concatenated and updated as hyperlink in the custom field on contact.

The hyperlink should redirect to the orignal Opp record.
Also the rich text field should become null once field A on contact is not equal to null.

Also the opp has look up to contact. So for a new Opp should be its own line, whilst an update should over write the existing link.

ANY HELP is much appreciated.
I have written a batch class that updates some date fields on the account. When one of the date field on the account date1 is equal to today , not only do i have to send an email, but i should send an email every 4 days starting from due date till a case is created for that account.  A case gets created for an account via forum assmebly and that flags the value on the account. How can i approach this. Hopefully someone can help.
this is the part of cod in batch that adds accounts to list to whom a mail is sent

 accList.add(theAccount);
            if(theAccount.RocketPro_Renewal_Status__c == Label.RenewalStatus_NeedsRenewal && theAccount.RocketPro_isRenewal_Required__c==true){
                emailaccList.add(theAccount);
            }
            if(theAccount.RocketPro_Next_Renewal_Date__c == System.today()){
                theAccount.RocketPro_Renewal_Status__c == Label.RenewalStatus_NeedsRenewal;
                Label.RenewalStatus_NeedsRenewal&&theAccount.RocketPro_isRenewal_Required__c = true;
                emailaccList.add(theAccount);
I have written the code for sending an email whena case is inserted into an account. There is anothre custom object with Master Detail to Account called Intrested party. User can select an user email in there to set the email the case insertion should be notifed to .i am am having difficultuies in wrtiting the test class with best practices. can someone help me with same please see both in here....
public class sendEmailIntrestedPartyCaseCreateUpdate {
    
    
    public static void sendEmailtoIntrestedPartyOnCase(List<Case> listOfCases){
        system.debug('****'+listOfCases);
        Set<Id> AccountIds = new Set<Id>(); 
        Map<Id,Set<String>> mapOfInterestedP1toAccounttoUserEmail = new Map<id,Set<String>>();
        Map<Id,Set<String>> mapOfInterestedAlltoAccounttoUserEmail = new Map<id,Set<String>>();
        for(Case caseRecord: listOfCases){
            if(caseRecord.AccountId!=null){
                AccountIds.add(caseRecord.AccountId);
                system.debug('***'+AccountIds );
            }
        }
        for(Interested_Party__c ipRecords: [SELECT Id, Name, Account__c, P1_Cases__c, All_Cases__c, UserEmail__c
                                            FROM Interested_Party__c where Account__c IN: AccountIds ]){
            
                                             
            //p1 map population
            if(ipRecords.P1_Cases__c){
                if(!mapOfInterestedP1toAccounttoUserEmail.containsKey(ipRecords.Account__c)){
                    
                    Set<String> lstUserEmails= new Set<String>();
                    lstUserEmails.add(ipRecords.UserEmail__c);
                    
                    mapOfInterestedP1toAccounttoUserEmail.put(ipRecords.Account__c,lstUserEmails);
                    system.debug('&&&&'+ mapOfInterestedP1toAccounttoUserEmail);
                    
                } else if
                    (mapOfInterestedP1toAccounttoUserEmail.containsKey(ipRecords.Account__c)){
                        Set<String> lstUserEmails= new Set<String>();
                        lstUserEmails.add(ipRecords.UserEmail__c);
                        
                        mapOfInterestedP1toAccounttoUserEmail.get(ipRecords.Account__c).add(ipRecords.UserEmail__c);
                    }
            }
            //all cases map population
            if(ipRecords.All_Cases__c){
                if(!mapOfInterestedAlltoAccounttoUserEmail.containsKey(ipRecords.Account__c)){
                    
                    Set<String> lstUserEmails= new Set<String>();
                    lstUserEmails.add(ipRecords.UserEmail__c);
                    
                    mapOfInterestedAlltoAccounttoUserEmail.put(ipRecords.Account__c,lstUserEmails);
                    
                } else if
                    (mapOfInterestedAlltoAccounttoUserEmail.containsKey(ipRecords.Account__c)){
                        Set<String> lstUserEmails= new Set<String>();
                        lstUserEmails.add(ipRecords.UserEmail__c);
                        
                        mapOfInterestedAlltoAccounttoUserEmail.get(ipRecords.Account__c).add(ipRecords.UserEmail__c);
                        system.debug('&&&&'+ mapOfInterestedAlltoAccounttoUserEmail);
                    }
            }
            /*Email messgging fom here*/
            
            List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();
           
            for(Case varCase: listOfCases){
                 Set<String> useremailsSet= new Set<String>();
                system.debug('case priority at this point'+ ''+ varCase.Priority);
                system.debug('mapOfInterestedP1toAccounttoUserEmail*****'  +mapOfInterestedP1toAccounttoUserEmail);
               if(mapOfInterestedAlltoAccounttoUserEmail.containsKey(varCase.AccountId)){
                  useremailsSet.addall(mapOfInterestedAlltoAccounttoUserEmail.get(varCase.AccountId));
                   system.debug('&&&&&&&((()()'+useremailsSet);
                }
               
                else if (varCase.Priority=='1-Critical'&& mapOfInterestedP1toAccounttoUserEmail.containskey(varCase.AccountId)){
                     system.debug('@@@@@#@#@#@'+ varCase.Priority + mapOfInterestedP1toAccounttoUserEmail + varCase.AccountId );
                   useremailsSet=mapOfInterestedP1toAccounttoUserEmail.get(varCase.AccountId);
                     system.debug('++++++++'+useremailsSet);
                }
                List<String> userEmailList = new List<String>();
                userEmailList.addaLL(useremailsSet);
                system.debug('453454353'+ userEmailList);
                IF(userEmailList.SIZE()>0){
                    Messaging.SingleEmailMessage sendEmailmsg = new Messaging.SingleEmailMessage();
                    sendEmailmsg.toaddresses= userEmailList;
                    
                    STring varcaseConcatenation= 'A new case has been created with Case number'+' '+ varCase.CaseNumber +' '+'and the associated Account Id is'+''+
                                                  + varCase.AccountId;
                    sendEmailmsg.SETplaintextbody(varcaseConcatenation);
                    String Subject = 'A new Case has been created for the account '+''+ varcase.Account_Name_Display__c;
                    sendEmailmsg.setSubject(Subject);
                    lstMsgs.add(sendEmailmsg);
                }
            }
            
            Messaging.sendEmail(lstMsgs);
            
        }
    }
}
 
@isTest
public class sendEmailIntrestedPartyCaseCreate_Test {
    
    @testSetup static void setup(){
        Account testAccount = new Account();
        testAccount.Name = 'Test for Send Email Case Trigger';
        insert testAccount;
        
        
        
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        UserRole ur = TestUtils.usrRole();
        User u = new User ();
        u.ProfileID = p.Id;
        u.Username ='Test@Testemail.com'+ System.currentTimeMillis(); 
        u.LastName ='TestLastname';
        u.Email ='smitha.vikram@compuware.com';
        u.Alias ='TestAlia';
        
        u.CommunityNickname ='TestCommunityNickname';
        //u.Employee_Number_CHRIS__c = '10';
        u.TimeZoneSidKey = 'America/New_York';
        u.LocaleSidKey = 'en_US';
        u.EmailEncodingKey = 'UTF-8';
        
        u.UserRoleId = ur.Id;
        u.LanguageLocaleKey = 'en_US';
        u.Division = 'APM';
        insert u;
    
        
        
        
        Interested_Party__c iprec = new Interested_Party__c();
        iprec.User__c=u.id;
        //iprec.All_Cases__c = true;
        iprec.P1_Cases__c= true;
        iprec.Account__c=testAccount.id;
        insert iprec;
    }
    
    
    
    
    
    static testmethod void unittest(){
        
        Account newAccount=[SELECT Id, Name, Interested_Party__c FROM Account Limit 1 ];
        Test.startTest();
        Case newCase = new Case(Origin ='Live Chat',Priority='1-Critical',Status ='New',Type ='Data' ,Sub_Type__c ='Delivery Problem',
                                Subject ='Test set up' ,Description ='test again' ,Resolution_Detail__c ='test test again', Accountid= newAccount.id );
        
        insert newCase;
        
        Test.stopTest();
        
    }
    
    
    
    
    
    
    
}

 
I have been asked to write trigger handler for this and i am used to writing it for regular triggers , this one has a get set method and I am not sure how to get it intoa trigger hanlder..fpr account....any help s appreciated
 
trigger CreateSiteAfterInsert on Account (after insert) {
    List<newsite> newsites = new List<newsite>();
    List<Sites__c> createsites = new List<Sites__c>();  
    
    public class newsite{
        Sites__c s {get; set;}
        public newsite(Account a){
            //if(a.CMA_Verified__c != true){
                s=new Sites__c();
                s.CMA_Verified__c = a.CMA_Verified__c;
                s.Geography__c = a.Geography_Account__c;
                s.Sales_Region__c = a.SalesRegionAcct__c;
                try{
                    s.put('Account__c',a.id);
                } catch (exception e){}
                s.Account_lkp__c = a.id;
                
                if(a.CorpClientNumber__c != null && a.SiteNumber__c != null){
                    s.Name = a.name + ' - ' + a.CorpClientNumber__c + '-' + a.SiteNumber__c;
                }
                else{
                    s.Name = a.name;
                }
                
                s.CPWR_Client_Number__c = a.CorpClientNumber__c;
                s.CPWR_Site_Number__c = a.SiteNumber__c;
                s.Account_Number__c = a.AccountNumber; 
                s.Phone__c = a.Phone;
                s.Fax__c = a.Fax;
                s.Website__c = a.Website;           
                s.CurrencyIsoCode = a.CurrencyIsoCode;
                s.Description__c = a.Description;
                
                s.Billing_Street_Address__c = a.BillingStreet;
                s.Billing_City__c = a.BillingCity;
                s.Billing_State_Province__c = a.BillingState;
                s.Billing_Zip_Postal_Code__c = a.BillingPostalCode;
                s.Billing_Country__c = a.BillingCountry;
    
                s.Shipping_Street_Address__c = a.ShippingStreet;            
                s.Shipping_City__c = a.ShippingCity;
                s.Shipping_State_Province__c = a.ShippingState;
                s.Shipping_Zip_Postal_Code__c = a.ShippingPostalCode;
                s.Shipping_Country__c = a.ShippingCountry;
                
                s.Old_Account_ID__c = a.id;
                
                //German Accounts
                s.Avenue_Documents__c = a.Avenue_Documents__c;
                
                //Japan Accounts
                s.Site_Name_Japan__c = a.Account_Name_Japan__c;
                s.Site_Name_Furigana__c = a.Account_Name_Furigana__c;
            //}
        }
    }
    
    for(Account a:Trigger.new){
        //if(a.CMA_Verified__c != true){
            newsites.add(new newsite(a));
        //}
    }

    for(Integer i=0;i<newsites.size();i++){
        createsites.add(newsites[i].s);
    }

    Database.SaveResult[] lsr = database.insert(createsites,false);
            
    Integer i=0;
    for(Database.SaveResult sr : lsr){
        if(!sr.isSuccess()){
            Database.Error err = sr.getErrors()[0];
            system.assert(false,'FAILED:Could not Create new Site Record. Please contact SFDC@compuware.com: '+err.getmessage());
        }
        i++;
    }
}
******

 
I have the following html file that callas a data to be displayed on LWC. hOWEVER, i need it to display as attached. How can i modify my html in order to display the header every 3-4 rows?
<template>
   
		<div class="slds-text-heading--large">All Training Modules</div><br/>
		<table class="slds-table slds-table_cell-buffer slds-table_bordered">
			<thead>
				<tr class="slds-line-height_reset">
					<th class="slds-text-title_caps" scope="col" >
						<div class="slds-truncate" title="Product">Products</div>
					</th>
					<th class="slds-text-title_caps" scope="col">
						<div class="slds-truncate" title="Release">Release</div>
					</th>
					<th class="slds-text-title_caps" scope="col">
						<div class="slds-truncate" title="Length">Length</div>
					</th>
					<th class="slds-text-title_caps" scope="col">
						<div class="slds-truncate" title="Description">Description</div>
					</th>
				</tr>
			</thead>
				<tbody>
                     <template  for:each={trainingModuleList} for:item="list">
                     <tr key={list.Id} class="slds-hint-parent">
                     <td data-label="title" class="slds-cell-wrap">
                        <p>
                            <lightning-formatted-url value={list.Download_Link__c}  label={list.Title__c} ></lightning-formatted-url>
                        </p>
                    </td>
                  <td data-label="title" class="slds-cell-wrap">
                        <p>{list.release}</p>
                    </td>
                    <td data-label="title" class="slds-cell-wrap">
                        <p>{list.Length__c}</p>
                    </td>
                         <td data-label="title" class="slds-cell-wrap">
                        <p> {list.Description__c} </p>
                   
                    
                    </td>

                </tr>
            </template>
        </tbody>
    </table>
</template>

User-added image
I have the following formula in the process builder, however the date conditon is not working ie: if the date is greater than 60 days i am not getting the field update? how do correctthat
AND(

IF(NOT(ISBLANK([CampaignMember].ContactId )),TRUE,FALSE), 

IF([CampaignMember].Contact.HasOptedOutOfEmail==FALSE,TRUE,FALSE),

IF(NOT(ISBLANK([CampaignMember].Contact.AccountId)), true, false),

 CASE([CampaignMember].Contact.Account.Licensed_Mainframe__c,"Active", 1,0)=1, 

IF(ISBLANK( [CampaignMember].Contact.Last_Survey_Sent_Date__c)|| 

[CampaignMember].Contact.Last_Survey_Sent_Date__c >=today()-60, true, false)
I have written a code where when a lead or contact is added to campaign, i need to check on some coditon and if they satisfy send out a survey link as an email and after that update last survey date field and type to a specific value. This is what i have so far, but not sure how to add email code without hitting email limit....
public class CampaignMembers_Hanlder {
    
    public static void getCampaignMembers(List<CampaignMember> campaignMember) {
        
        Set<id> setOfContactIds = new Set<id>();
        Set<id> setOfLeadIds= new Set<id>();
        
        if(campaignMember!=null){
            for(CampaignMember varCampaignMember: campaignMember){
                if(varCampaignMember.ContactId!=null){
                    
                    setOfContactIds.add(varCampaignMember.ContactId);
                }
                
                if(varCampaignMember.leadId!=null){
                    setOfLeadIds.add(varCampaignMember.leadId);
                    
                }
            }
            
            for(Contact varContactRecord:[Select id, HasOptedOutOfEmail,Last_Survey_Sent_Date__c,account.Licensed_Mainframe__c,
                                          Last_Survey_Sent_Type__c from contact where id IN:setOfContactIds])
            {
                If(varContactRecord.HasOptedOutOfEmail==false && varContactRecord.account.Licensed_Mainframe__c =='Active'){
                    
                    
                    if(varContactRecord.Last_Survey_Sent_Date__c!=null && varContactRecord.Last_Survey_Sent_Date__c>= system.today()-60){
                        
                        
                        String[] toAddresses = new String[] {'user@acme.com'};
                            
                            }
                    
                }
                
            }        
            
            for(Lead varLeadRecord: [Select id, HasOptedOutOfEmail, Last_Survey_Sent_Date__c, 
                                     Last_Survey_Sent_Type__c, SFDC_Account__r.Licensed_Mainframe__c from Lead WHERE id IN:setOfLeadIds]){
                                         
                                         
                                         If(varLeadRecord.HasOptedOutOfEmail==false && varLeadRecord.SFDC_Account__r.Licensed_Mainframe__c =='Active'){
                                             
                                             
                                             if(varLeadRecord.Last_Survey_Sent_Date__c!=null && varLeadRecord.Last_Survey_Sent_Date__c>= system.today()-60){
                                                 
                                                 
                                                 String[] toAddresses = new String[] {'user@acme.com'};
                                                     
                                                     }
                                             
                                         }
                                         
                                     }    
            
        }
    }
    
}

 
I have to write a trigger where i have a custom object in the related list of the parent opportunity object. The parent Opportunity has a comments field.
The user is allowed to create a new text under the custom object and every time a new record is created or updated the value in the parent must be replaced with the new value,

I can write a basic triiger on after insert and after udpated. Where i am not clear is the logic that a record is updated will not be the latest record created, how can the logic be added such the any record that is updated will get replaced with edited one.Kindly help me 
I have the following Apex class and also the a flow calling the apex class. I have made an attempt to write the test class, but  i know its not even close, can someone help me through this?
bal with sharing class AddCommentbuttononOpp
{
   @InvocableMethod
  Webservice static void  getOppRecord(list<FlowRequest> oppId){
 if(oppId!=NULL)
{
 if( oppId[0].varOpptyRecord.Comments_Next_Steps__c!=null){
           oppId[0].varOpptyRecord.Comments_Next_Steps__c=System.today().format()+' '+  oppId[0].varOpptyRecord.Comments_Next_Steps__c;
           string temp =  oppId[0].varOpptyRecord.Description;
     if(temp==null && !string.isNotBlank(temp)){
     oppId[0].varOpptyRecord.Description =  oppId[0].varOpptyRecord.Comments_Next_Steps__c;  
         
     }else if(temp!=null && string.isNotBlank(temp)){
        oppId[0].varOpptyRecord.Description =  oppId[0].varOpptyRecord.Comments_Next_Steps__c +'\n' +temp;
     }
         
     }
update oppId[0].varOpptyRecord;
}
}
//One for getting the values from Flow to Apex a
 
global class FlowRequest
    {
        @InvocableVariable(label = 'Opportunity Record')
        public Opportunity varOpptyRecord;
}

}

test class
@isTest
public class AddCommentbuttononOppTest {
    Static testMethod void unittest(){
  try
  {
  
   Opportunity newOpp = new Opportunity( StageName = '1 - Discover Opportunity', CloseDate = Date.today() + 30, Name = 'Test Opportunity 33', Comments_Next_Steps__c='Go tigers',Description='go tigers Opportunity');
  
        insert newOpp;
        system.debug('Inserted Test Opportunity: ' + newOpp.id);
      }catch(DMLException d){ 
        system.debug(d.getDMLMessage(0));   
      }
          test.startTest();
          
    AddCommentbuttononOpp.FlowRequest varWrapper = new  AddCommentbuttononOpp.FlowRequest();
          
          varWrapper.varOpptyRecord.Comments_Next_Steps__c='test';
           AddCommentbuttononOpp.getOppRecord( new List< AddCommentbuttononOpp.FlowRequest>{  varWrapper   }) ; 
  

        Test.stopTest();
    }
}

so far

So the request I have is to create a custom button on opportunity that pops a window allowing the user to add a comment
: That comment must be appended with today date and should be added to comment section
 Next time another comment is added the previous comment should be added to a description filedSo on so forth
 Where comment and description will be read only fields on the page
 Comment is Rich text field
 
i have my apex class
 
public with sharing class AddCommentbuttonOpportunity { 
public Opportunity getComments{get;set;} 
public AddCommentbuttonOpportunity(Apexpages.StandardController controller){ List<String> fields= new List<String> {'Comments_Next_Steps__c'}; controller.addFields(fields); this.getComments=(Opportunity)controller.getRecord(); if(getComments.Comments_Next_Steps__c!=null) { getComments.Comments_Next_Steps__c = System.today() + ' ' + getComments.Comments_Next_Steps__c; string temp= getComments.Description; if(temp==null && String.isBlank(temp)){ getComments.Description= getComments.Comments_Next_Steps__c; }else If(temp!=null && String.isNotBlank(temp)){ getComments.Description= getComments.Comments_Next_Steps__c +'/n' +temp; } } } public PageReference save() { insert getComments; return new PageReference('/'+getComments.id); } } This is my VF page <apex:page sidebar="false" standardController="Opportunity" extensions="AddCommentbuttonOpportunity"> <apex:form > <apex:pageBlock title="Add a New Comment"> <apex:pageBlockSection > <apex:inputfield value="{! Opportunity.Comments_Next_Steps__c}" /> <br/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page> but when i enter value and click save i am getting error ' what am i missing

​​​​​​​
I have wriiten the following apex class that a flow calls.I am clueless on how to write the unit test for this, any leads or logic i can get started with is much appreciated.
global with sharing class AddCommentbuttononOpp
{
   @InvocableMethod
  Webservice static void  getOppRecord(list<FlowRequest> oppId){   // here the value of List is list of flows records of opprotinity type from the flow and the value is obtained from below
                                                                   // class flow request.
 if(oppId!=NULL)
{
 if( oppId[0].varOpptyRecord.Comments_Next_Steps__c!=null){             // here we pass the opportunity record ie in the first position and hence[0] and that has for the opprottunity.
           oppId[0].varOpptyRecord.Comments_Next_Steps__c=system.now().format('dd_MM_yyyy') +' '+  oppId[0].varOpptyRecord.Comments_Next_Steps__c;
           string temp =  oppId[0].varOpptyRecord.Description;
     if(temp==null && !string.isNotBlank(temp)){
     oppId[0].varOpptyRecord.Description =  oppId[0].varOpptyRecord.Comments_Next_Steps__c;  
         
     }else if(temp!=null && string.isNotBlank(temp)){
        oppId[0].varOpptyRecord.Description =  oppId[0].varOpptyRecord.Comments_Next_Steps__c +'\n' +temp;
     }
         
     }
update oppId[0].varOpptyRecord;
}
}
//One for getting the values from Flow to Apex a
 
global class FlowRequest
    {
        @InvocableVariable(label = 'Opportunity Record')  // this is a variable of data type opportunity just like an integer or decimal 
		                                                     that is declared in here so that the values declared in flow ie: the for the object with fields that gets populated from flow and is 
															 passed on from here into the class vairable oppid above.
															 here we could add mutiple values incase the flow needs any other data type such as account of contact etc.
        public Opportunity varOpptyRecord;
}

}

 
I have written a batch class that updates some date fields on the account. When one of the date field on the account date1 is equal to today , not only do i have to send an email, but i should send an email every 4 days starting from due date till a case is created for that account.  A case gets created for an account via forum assmebly and that flags the value on the account. How can i approach this. Hopefully someone can help.
this is the part of cod in batch that adds accounts to list to whom a mail is sent

 accList.add(theAccount);
            if(theAccount.RocketPro_Renewal_Status__c == Label.RenewalStatus_NeedsRenewal && theAccount.RocketPro_isRenewal_Required__c==true){
                emailaccList.add(theAccount);
            }
            if(theAccount.RocketPro_Next_Renewal_Date__c == System.today()){
                theAccount.RocketPro_Renewal_Status__c == Label.RenewalStatus_NeedsRenewal;
                Label.RenewalStatus_NeedsRenewal&&theAccount.RocketPro_isRenewal_Required__c = true;
                emailaccList.add(theAccount);
I have to write a trigger where i have a custom object in the related list of the parent opportunity object. The parent Opportunity has a comments field.
The user is allowed to create a new text under the custom object and every time a new record is created or updated the value in the parent must be replaced with the new value,

I can write a basic triiger on after insert and after udpated. Where i am not clear is the logic that a record is updated will not be the latest record created, how can the logic be added such the any record that is updated will get replaced with edited one.Kindly help me 

So the request I have is to create a custom button on opportunity that pops a window allowing the user to add a comment
: That comment must be appended with today date and should be added to comment section
 Next time another comment is added the previous comment should be added to a description filedSo on so forth
 Where comment and description will be read only fields on the page
 Comment is Rich text field
 
i have my apex class
 
public with sharing class AddCommentbuttonOpportunity { 
public Opportunity getComments{get;set;} 
public AddCommentbuttonOpportunity(Apexpages.StandardController controller){ List<String> fields= new List<String> {'Comments_Next_Steps__c'}; controller.addFields(fields); this.getComments=(Opportunity)controller.getRecord(); if(getComments.Comments_Next_Steps__c!=null) { getComments.Comments_Next_Steps__c = System.today() + ' ' + getComments.Comments_Next_Steps__c; string temp= getComments.Description; if(temp==null && String.isBlank(temp)){ getComments.Description= getComments.Comments_Next_Steps__c; }else If(temp!=null && String.isNotBlank(temp)){ getComments.Description= getComments.Comments_Next_Steps__c +'/n' +temp; } } } public PageReference save() { insert getComments; return new PageReference('/'+getComments.id); } } This is my VF page <apex:page sidebar="false" standardController="Opportunity" extensions="AddCommentbuttonOpportunity"> <apex:form > <apex:pageBlock title="Add a New Comment"> <apex:pageBlockSection > <apex:inputfield value="{! Opportunity.Comments_Next_Steps__c}" /> <br/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page> but when i enter value and click save i am getting error ' what am i missing

​​​​​​​
Hi, 
I want to use custom metadata to make the mapping dynamic in salesforce. Can somebody please help how should i do it?
code snippet for mapping:
for(Staging_Course__c  objB: [SELECT test_Field__c , test_field_1__c,name  FROM Staging_Course__c WHERE Unique_Id__c  IN: setUniqueId])
			{
              
				lstObjC.add(new Course__c( test_Field__c  = objB.test_Field__c, test_field_1__c  = objB.test_field_1__c , name = objB.name ));

I created a custom metadata record but i am not sure how to use to make the mapping dynamic in the above apex code.
User-added image 

Thanks
I have placed a custom button on a Case List view.  The button, when clicked, needs to validate whether any case records were actually selected.  That part is done simply with a Javascript OnClick button with the following code:

{!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} 

var selected = {!GETRECORDIDS($ObjectType.Case)}; 

if (selected[0] == null) { 

    alert("Please select at least one Case.")
} 

else {

     window.location = 'apex/MyPage';
}

The problem is that when validation passes (i.e. it goes to the MyPage visualforce page) the selected records aren't passed along.  Here is my VF page thus far:

<apex:page standardController="Case" recordSetVar="cases">
   <apex:form >
       <apex:pageBlock title="MyPage" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="MyButton"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Information" columns="2">
                <apex:inputCheckBox value="{!case.test__c}" selected="true" required="true"/>
                <apex:pageBlockSectionItem />
                <apex:inputField value="{!case.test2__c}" showDatePicker="true" required="true"/>
                <apex:inputField value="{!case.test3__c}" showDatePicker="true" required="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Cases">
                <apex:pageBlockTable value="{!selected}" var="case">
                    <apex:column value="{!case.casenumber}"/>
                    <apex:column value="{!case.subject}"/>
                    <apex:column value="{!case.status}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>   
</apex:page>
The goal is to have the custom button on the List view validate whether records are checked, then when validation passes have those records displayed in the block table on the VF page.  I can get one or the other to work, but not both at the same time.  If I change the button to go directly to the VF page, the selected records appear perfectly, but no validation occurs (i.e. it allows redirect when no records are selected).  If I have the button set to the Javascript code it validates the records but doesn't display the selected records on the VF page.

I have searched the internet for hours on everything I could think of and couldn't find anything to help me.  

Can anyone out there offer a solution?

THANKS!!

I need to export a report as a CSV to an FTP site or email it on a daily or weekly basis.

 

I have a Report.  I need to get the report out of Salesforce somehow into CSV format.

 

Ideally, this would be scheduled.


I'm a developer so I can do developer stuff.  However, I don't know APEX and I don't know VisualForce.  I can get someone to do that stuff if we need to.


Thanks!

  • July 26, 2011
  • Like
  • 2