• Prakhar Saxena 19
  • NEWBIE
  • 210 Points
  • Member since 2018
  • CX Cloud Developer
  • CRMIT Solutions


  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 30
    Replies
Hi,
plz tell me whats wrong with my code:
global class batchaccountdescupdate implements database.batchable<sObject>,database.stateful{
global Database.QueryLocator start(Database.BatchableContext BC){
string query='SELECT Description FROM Account';
return Database.getQueryLocator(query);
}
global void execute(database.batchablecontext BC, list<Account> scope){
for(Account a: scope){
if(a.Description=='Not Available')
a.Description='Please fill details, else record will be made inactive';
}
update scope;
}
global void finish(database.batchablecontext BC,list<Account> scope){
integer totalemployeecount=0;
for(Account a: scope){
totalemployeecount=totalemployeecount+a.NumberOfEmployees;
}
update scope;
}
}
here is the error im getting:
Error: Compile Error: Class batchaccountdescupdate must implement the method: void Database.Batchable<SObject>.finish(Database.BatchableContext) at line 1 column 14
thanks.
Hello - Hoping someone can help out with a validation rule that's not working in flow. I have a screen elment with a text field called "Last_Name_1" and a text field called "Phone_1". If the last name is not blank, there must be a phone number. I cannot get the vaidation rule to fire. I tested the same validation rule on the object fields and it works as expected. Below is my validation rule.  

AND(
NOT(ISBLANK({!Last_Name_1})),
ISBLANK({!Phone_1}))

User-added image

 
Can anyone help me write Test Class for below Apex Class.

public class CheckSalesTeam {
    public static boolean IsSalesTeam=false;
    public static Boolean profileApprover(){
        List<Profile> profileList = New List<Profile>([SELECT Name FROM PROFILE WHERE Id = :UserInfo.getProfileId() LIMIT 1]);
        if(profileList[0].Name !='Sales Approver')
            IsSalesTeam=True; 
        
        return  IsSalesTeam;
    }
    
}
1. Create a Formula Field named Domain on Contact Object, This should give me the Domain from Email Field on Contact Object. For Example: - If I save the Contact with Email as testuser@gmail.com, then formula field of Domain should have value “gmail”
2. Add a text Field at Account Level named as Contact Unique Domains
3. Create a trigger on Contact, Which handles Insert / Update / Delete / Undelete scenario. Trigger should get the Account Id from the Contact and then read all the related contacts from that Account and then Store the unique domains to the Account Level. For Example If I have below 3 contacts
Email - testuser1@gmail.com and Domain - gmail
Email - testuser2@yahoo.com and Domain as yahoo
Email - testuser3@gmail.com and Domain as gmail
So there are two unique domain gmail and yahoo, hence my Account text field will be populated with value gmail;yahoo
Hello All,

We have four contact lookup in the custom object called 'Reservation Center'. Values entered in the lookup fields should be unique. 
If we provided value for Contact1__c as Test Contact, then rest of other three lookup field should not use Test Contact.

Is this possible in the configuration? If not, please provide suggestion on how to achieve this in code.
Hello, can someone point me in the right direction on writing a test class for this apex controller (for a lightning component DataTable). Below is my controller and test class so far. My test class is covering 55% and covers the getRecords soql method but I cannot get the test class to cover the update list method (database.update).

The objects parent, child, and grandchild are in masterdetil relationships and require lookups to one another so there will always be a parent, child, and grandchild in the data model. 

Thanks so much!
 
Controller: 

public class LightningDataTableCtrl {
    @AuraEnabled    
    public static List <grandchild__c> getRecords (String parentId) {   
        List <grandchild__c> updatedObjList = 
            [SELECT Id,
             Name,
             Text_Formula__c,
             Status_Picklist__c,
             Hours_Number_Field__c,
             Custom_Lookup__c,
             Number_Field__c,
             Number_Field_2__c,
             Custom_Picklist__c
             FROM grandchild__c
             WHERE child__r.parent__c = :parentId
             ORDER BY Name ASC];
        return updatedObjList;
    }    
    @AuraEnabled    
    public static void updateRecords( List <grandchild__c> updatedObjList ) {    
        try {  
            Database.update (updatedObjList); 
            
        } catch(Exception e) {  
            
        }  
    }  
}

Test Class: 

@isTest
public class LightningDataTableCtrlTest {
    @isTest (SeeAllData = 'true') static void testGetRecords() {
       
        parent__c parent = new parent__c(Name = 'Lightning Data Table Apex Test', 
                                                                          parent_type_picklist__c = 'Duration');
        insert parent;
        
        child__c child = new child__c(Name = 'Apex Test Phase', 
                                                                                    parent__c = parent.Id);
        insert phase;
        
        grandchild__c grandchild = new grandchild__c(Name = 'Apex Test Task',
                                                                                 child__c = child.Id,
                                                                                 Number_field__c = 1, 
                                                                                 Date_field__c = Date.newInstance(2018, 4, 27),
                                                                                 Number_Field_2__c = 1);
        insert task;
        // List covers the soql and 'getRecords' method of the class.
        List <grandchild__c> getRecords = LightningDataTableCtrl.getRecords(granchild.id);
        
        // Test method to cover update method in controller        
    }
}

 
I have few links in the Custom Links Standard Component present on the Home Page Component.

User-added image

I need to show these bookmarks and URLs on a Visualforce Page. Didn't find a way to query Custom Links Standard Component, so tried by creating new Custom Component and adding links like this:

User-added image

and then added these links on the newly created Custom Component named 'Hyperlinks'.

User-added image

Finally, added this Custom Component on the Home Page Layout.

I queried the WebLink object and got the Labels and URLs of the links. But I am not getting a way to query links present only on this 'Hyperlinks' Custom Component.

User-added image
Is this the correct way of just displaying the Custom Links Home Page Component on a Visualforce page or is there a way to directly query Custom Links Standard component under Home Page Components in Salesforce Classic?

Thanks.
Hello,

I'm working to deploy from sandbox to our production environment.

When I validate the inbound changeset in our production environment, I get the following error:

System.NullPointerException: Attempt to de-reference a null object
Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1

line 148 reads:         System.assert(controller.getFieldTypeOptions().size()>1);

I've done some research and have seen you can possibly comment-out the line in question, or de-reference the null so that I guess a new object is created and the code works properly (I'm not quite sure I understand this one) I've tried to edit this code to make it work, but still have errors. Can anyone help me, please?!

I have very limited coding and Salesforce experience, so any clarity and insight is appreciated!

Here is the Apex Class Code: 
/**
 * This class contains unit tests for validating the behavior of MassUpdateController
 * and triggers.
 */
@isTest
private class MassUpdateSimpleControllerTest {


    static testMethod void singleUpdateTest() {
        Opportunity o = new Opportunity();
        List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        setCtr.setSelected(new Opportunity[]{o});
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.assertEquals(1, controller.getRecordSize());
        
        System.assert(controller.getFieldTypeOptions().size()>1);
        
        system.assertEquals(1, controller.objsToUpdate.size());
        
        String value = '123test';
        controller.fieldName='name';
        controller.valueToUpdate=value; 
        //controller.convertedFieldData = controller.convertUserInputToFieldData(); 
        controller.step4();
        controller.step5();
        
        System.assert(o.name==value);
        
        value ='123';
        controller.step3();
        controller.fieldName='amount';
        controller.valueToUpdate=value; 
        controller.step4();
        controller.step5();
        
        System.assert(o.amount==decimal.valueOf(value));
        
/*      value ='true';
        controller.fieldName='IsPrivate';
        controller.step3();
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        
        System.assert(o.IsPrivate); */
        // make sure no exception from display tips
        System.assertEquals(controller.getFieldInfoToDisplay()!=null,true);
                
        value ='2009-4-7';
        controller.fieldName='CloseDate';
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        System.assert(o.CloseDate==Date.valueOf(value));
        
        value ='Closed';
        controller.fieldName='StageName';
        controller.valueToUpdate=value;     
        controller.step4();
        controller.step5();
        System.assert(o.StageName=='Closed');
    }
    
 /*   static testMethod void massUpdateAsStandardUserTest() {
        
        Profile p = [select id from profile where name='Standard User'];
        User u = new User(alias = 'standt', email='standarduser@testorg.com',
          emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
          localesidkey='en_US', profileid = p.Id,
          timezonesidkey='America/Los_Angeles', username='standarduser@test.com');
        
        System.runAs(u) {
          Opportunity o = new Opportunity();
          List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
          ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
          setCtr.setSelected(new Opportunity[]{o});
          MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
          System.assertEquals(1, controller.getRecordSize());
        
          System.assert(controller.getFieldTypeOptions().size()>1);
        
          system.assertEquals(1, controller.objsToUpdate.size());
        
          String value = '123test';
          controller.fieldName='name';
          controller.valueToUpdate=value;       
          controller.save();
        
          System.assert(o.name==value);
         
        }
    }  */
    
    static testMethod void linkTest() {
        Opportunity o = new Opportunity();
        List<Opportunity> oppList = [SELECT name FROM Opportunity LIMIT 20];
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        setCtr.setSelected(new Opportunity[]{o});
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        
        // verify following exceptions will not cause exception
        System.assert(controller.step1()!=null);
        System.assert(controller.step2()!=null);
        controller.getFieldTypeOptions();
        System.assert(controller.step3()!=null);
        System.assert(controller.step4()!=null);
        System.assert(controller.step5()!=null);
        //System.assert(controller.cancel()!=null);
        
        System.assert(controller.getFieldTypeOptions()!=null);
    }
    
    static testMethod void fieldTest() {
        
        List<Opportunity> oppList = new Opportunity[]{};
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.assert(controller.cancel()!=null);
        System.assert(controller.getFieldTypeOptions()==null);
    }
    
    static testMethod void miscTest() {
        
        List<Opportunity> oppList = new Opportunity[]{};
        
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        
        System.assert(controller.getNow(true)!=null);
        System.assert(controller.getNow(false)!=null);
        System.assert(controller.getRecordSize()==0);
        System.assert(controller.getPicklistValues()==null);
    }
    
    @isTest(SeeAllData=true)
    static void testOpportunityInRelatedList(){
        List<Opportunity> oppList = [SELECT name, AccountId FROM Opportunity LIMIT 20];
        ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(oppList);
        apexpages.currentpage().getparameters().put('id' , oppList.get(0).AccountId);
        MassUpdateSimpleController controller = new MassUpdateSimpleController(setCtr);
        System.debug('list: ' + oppList);
        
        System.assert(controller.getFieldTypeOptions().size()>1);
        
        //system.assertEquals(1, controller.objsToUpdate.size());
        
        String value = '123test';
        controller.fieldName='name';
        controller.valueToUpdate=value; 
        //controller.convertedFieldData = controller.convertUserInputToFieldData(); 
        controller.lexstep4();
        controller.lexstep5();
        List<Opportunity> selectList = (List<Opportunity>)setCtr.getSelected();
        System.assert(selectList.get(0).name==value);
        System.assert(controller.displayTexField=='true');
        System.assert(controller.displayCheckBox=='false');
        System.assert(controller.displayPicklist=='false');
        System.assert(controller.displayTextArea=='false');
        
         value ='Closed';
        controller.lexstep3();
        controller.fieldName='StageName';
        controller.valueToUpdate=value;     
        controller.lexstep4();
        controller.lexstep5();
        System.assert(selectList.get(0).StageName=='Closed');
        System.assert(controller.displayTexField=='false');
        System.assert(controller.displayCheckBox=='false');
        System.assert(controller.displayPicklist=='true');
        System.assert(controller.displayTextArea=='false');
        
        
    }
}
Hi,
plz tell me whats wrong with my code:
global class batchaccountdescupdate implements database.batchable<sObject>,database.stateful{
global Database.QueryLocator start(Database.BatchableContext BC){
string query='SELECT Description FROM Account';
return Database.getQueryLocator(query);
}
global void execute(database.batchablecontext BC, list<Account> scope){
for(Account a: scope){
if(a.Description=='Not Available')
a.Description='Please fill details, else record will be made inactive';
}
update scope;
}
global void finish(database.batchablecontext BC,list<Account> scope){
integer totalemployeecount=0;
for(Account a: scope){
totalemployeecount=totalemployeecount+a.NumberOfEmployees;
}
update scope;
}
}
here is the error im getting:
Error: Compile Error: Class batchaccountdescupdate must implement the method: void Database.Batchable<SObject>.finish(Database.BatchableContext) at line 1 column 14
thanks.
I need some help please with a formula field.   I am trying to write a formula that references another field on the same object that is a picklist field.    I want to have the value in this new field to be based on the picklist value from the other field.  The formula that I am trying to write consists of:
 
IF(ISPICKVAL(Loan_Documentation__c = "Attorney Prepared", Yes,Bypass CDP,
ISPICKVAL(Loan_Documentation__c = "Internal Loan Agreement and Attorney Closed",Yes, Bypass CDP,
ISPICKVAL(Loan_Documentation__c, = "Internal Loan Agreement and No Attorney Closed", No,
ISPICKVAL(Loan_Documentation__c, = "No Loan Agreement Needed", No
)
)
)
)
)
I get an error message with this that states "Error:  Syntax error.  Found 'Bypass'.    What am I doing wrong?
 
Thank you!
Hello - Hoping someone can help out with a validation rule that's not working in flow. I have a screen elment with a text field called "Last_Name_1" and a text field called "Phone_1". If the last name is not blank, there must be a phone number. I cannot get the vaidation rule to fire. I tested the same validation rule on the object fields and it works as expected. Below is my validation rule.  

AND(
NOT(ISBLANK({!Last_Name_1})),
ISBLANK({!Phone_1}))

User-added image

 
Hi,

I have tried to show list of related Case files(Content Documents) in a lightning component on Account page. While querying I got 12000 related case records for a account. Now I have to fetch the Content Document IDs through Content Document Link. When i run the below SOQL I am getting only few Content Document Link records but I have 11 case records which are having files. The below query results only 5. Is there a limitation on WHERE clause or ContentDocument Link while querying huge number of records?

CaseList=SELECT id FROM Case WHERE AccountId=:accID // This results 12000 case records
List<ID> caseIDs=new List<Id>();
For(Case c:CaseList)
{
                 caseIDs.add(c.Id);

}
SELECT LinkedEntityId,LinkedEntity.Name, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId=:caseIDs // This results only 5 records but we have 11 ContentDocuments

Thanks in advance.
I'm trying to deploy a package to a scratch org via the SFDX CLI using the sfdx force:mdapi:deploy command. 

See screenshot below for exact error message.

I have a "Reinsurer" picklist value on the Account object's Type field that I believe is causing the error.

I've done some research and found two others with a similar error:  
(1) was a version conflict issue and changing the version in package.xml fixed this.  My package.xml shows version 46.0.  Would changing my version fix this?  If so, what version should I use?
(2) Suggestion was to "include same picklist in change set while deployment".  I'm not using change sets.  But maybe the picklist is a package component I didn't add?  I double checked and couldn't find any missing componenets but maybe I missed it?

Also, I don't even use the Account object's Type field.  So if there's a way to ignore or exclude this field from the package and that's easier then that works too.


User-added image

Bonus: I think the app invalid cross reference error might be related to this issue (https://success.salesforce.com/issues_view?id=a1p3A000000mCIdQAM&title=invalid-cross-reference-id-deploying-custom-app-with-profileactionoverrides-referencing-new-profiles-in-same-deployment) but not sure.  Ant insights regarding that issue would be appreciated
trigger acctrigger on Account (before insert) {
    if(trigger.isBefore){    
      if(trigger.isInsert){
      list<Account> acc = [SELECT Id,Name from Account];
      for(Account ta: trigger.new){
          for(Account a: acc){
             if(ta.Name == a.Name){
               newval.addError('sorry you cannot add this account its already been in database');
           }
         }
       }
     }
   }
 }
Can anyone help me write Test Class for below Apex Class.

public class CheckSalesTeam {
    public static boolean IsSalesTeam=false;
    public static Boolean profileApprover(){
        List<Profile> profileList = New List<Profile>([SELECT Name FROM PROFILE WHERE Id = :UserInfo.getProfileId() LIMIT 1]);
        if(profileList[0].Name !='Sales Approver')
            IsSalesTeam=True; 
        
        return  IsSalesTeam;
    }
    
}
Is there a way to have a tierd oppotunity  within an opportunity? 

As an example, Lets say my Account is Macdonalds, and I have an opportunity as Macdonalds Location number X, 

With in this opportunity I want to create several sub opportunities and have them roll up to the total opportunity at Macdonalds Location number X. 

At this location I want a sub opportunity to sell 
Coke at Macdonalds Location number X
Burger patties at "  "
French Fries at "  " 
Ect, 

I dont want these all as seperate opportunites because i want them to be all assoicated with the one Location Opportunity, and ultimately the account is Macdonalds. 

The other thing is that the sub opportunites are not a product, rather a service that will always have different rates etc. 

Any help would be most appricated. 
Hi All,

I have created a lightning component to display a public site from which we can get customers sigup.
I have created the Lightning component for this and able to view the page but, I am unable to fire the toast messages in this.
And also my Save button is not getting disabled after clicking on it. 
This is my code. Any help to solve this is appreciated. Thanks in advance.
Lightning component:
<aura:component controller="CreateContactrecordController" 
implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickAction,
            flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,lightning:isUrlAddressable,
            lightning:actionOverride,force:hasRecordId"
             access="global" >
    <!-- Include Static Resource-->
    <ltng:require styles="/resource/bootstrap/css/bootstrap.min.css" 
scripts="/resource/bootstrap/js/jquery.js,/resource/bootstrap/js/bootstrap.min.js"/>
    <!--aura:attribute name="isSpinner" type="boolean" default="false"/-->
    <aura:attribute name="FirstName" type="String" default="" />
    <aura:attribute name="LastName" type="String" default="" />
    <aura:attribute name="Mobile" type="String" default="" />
    <aura:attribute name="Email" type="String" default="" /> 
    <aura:attribute name="Store" type="String" />
    <aura:attribute name="LanguageList" type="List" />
    <aura:attribute name="SelectedLanguage" type="String" />
    <aura:attribute name="isHide" type="Boolean" default="false" />
    
     <aura:handler name="onSaveSuccess" event="force:recordSaveSuccess" action="{!c.handleSaveSuccess}"/>
 <force:recordEdit aura:id="edit" recordId=""/>
 <ui:button label="Save" press="{!c.save}"/>
    
    <div class="slds-page-header">
        <div class="slds-align_absolute-center">
            <div class="slds-text-heading_large">
                <div class="slds-m-top_xx-large">
                    Customer Subscription Form
                </div>
            </div>
        </div>
    </div>
    <br/>
    <aura:handler name="init" action="{!c.doinIt}" value="{!this}"/> 
    <div class="slds-form-element__control">
         <lightning:input label="First Name" name="firstname" type="text" required="true" value="{!v.FirstName}" />
        <br/>
        <lightning:input label="Last Name" name="lastname" type="text" required="true" value="{!v.LastName}" />
        <br/>
        <lightning:input label="Mobile" type="tel" value="{!v.Mobile}"/>
        <br/>
        <lightning:input label="Email" name="email" type="email" required="true" value="{!v.Email}" />
        <br/> 
        <lightning:input label="Store" type="Text" name="Store" value="{!v.Store}" />
        <br/> 
        <lightning:select label="Language" name="Language" value="{!v.SelectedLanguage}">
            <aura:iteration items="{!v.LanguageList}" var="Language">
                <option value="{!Language}" text="{!Language}"></option>
            </aura:iteration>
        </lightning:select>
        <br/>
   <lightning:button variant="brand" disabled="{!v.isHide}" label="{!v.isHide == true ? 'Save' : 'Save'}" onclick="{!c.savecustomerForm}" /> 
    <!--lightning:button variant="brand" disabled="{!v.isSpinner}" label="{!v.isSpinner == true ? 'Saving...' : 'Save'}" onclick="{!c.savecustomerForm}" /--> 

    </div>       
</aura:component>

Controller.js:

({
    doinIt: function(component, event, helper){ 
        var action = component.get('c.getPickListValuesIntoList');          
         // method name i.e. getEntity should be same as defined in apex class         
         // params name i.e. entityType should be same as defined in getEntity method        
        //action.setParams({ "entityType" : component.get('v.componentString') });         
            action.setCallback(this, function(a){             
            var state = a.getState(); // get the response state             
            if(state == 'SUCCESS') {
               component.set('v.LanguageList',a.getReturnValue()); 
            }        
            });         
            $A.enqueueAction(action); 
    },
     savecustomerForm: function(component, event, helper) {
        console.log('Create record');
         var action = component.get("c.save");
        //Setting the Apex Parameter
         action.setParams({"FirstName":component.get("v.FirstName"), "LastName":component.get("v.LastName"),
                           "Email":component.get("v.Email"), "Mobile":component.get("v.Mobile"), 
                           "Store":component.get("v.Store"), "Language":component.get("v.Language")
            });
        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            var isContactexists = a.getReturnValue();
            //check if result is successfull
           
            if(state == "SUCCESS"){
                //Reset Form
                var newContact = {'sobjectType': 'Contact','FirstName': '','LastName': '','Email': '',
                                  'Mobile': '', 'Store__C': '','Language__c' : ''};
                //resetting the Values in the form
                component.set("v.Contact",newContact);
                if(isContactexists===true){
              //alert('Record Created Successfully');
                    component.find("edit").get("e.recordSave").fireeSuccess : function(cmp, event) {
                     // Display the save status
                     var toastEvent = $A.get("e.force:showToast");
                     toastEvent.setParams({
                     "title": "true!",
                     "message": "My Custom Record Saved Successfully"
 });
 toastEvent.fire();
                    }
                    
                component.set('v.isHide', true);  
                }
                else { 
                   alert('Record already exists'); 
                   
                }
            }
            else if(state == "ERROR"){
            alert('Error in calling server side action');
           
            }
            
        });
                
         $A.enqueueAction(action);}

})

Apex controller:

public class CreateContactrecordController {
@AuraEnabled
     public static List<String> getPickListValuesIntoList()
     {
       List<String> pickListValuesList= new List<String>();
        Schema.DescribeFieldResult fieldResult = Contact.Language__C.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            pickListValuesList.add(pickListVal.getLabel());
        }    
        return pickListValuesList;
    }
 @AuraEnabled   
    public static Boolean save(String FirstName, String LastName, String Email, String Mobile, String Store, String Language )
    {
        List<Contact> Contact = [SELECT Id, Email From Contact WHERE Email=:Email];
         if(contact.size() > 0){
             return false;
        }else{
            Contact con=new Contact(); 
            con.FirstName = FirstName;
            con.LastName = LastName;
            con.Email = Email;
            con.MobilePhone = Mobile;
            con.Store__c = Store;
            con.Language__c = Language;
            insert con;
            return true;
        }
    }
    }
 
Hello!

My goal is to require 2 fields prior to a user rejecting an approval process. A validation rule is not working, and other resources are stating to use a trigger. I am purely declarative, so my attempting to tweak the trigger base that I found is not perfect. Can someone assist in correcting it? Please feel free to explain what's being updated and why as I have no issue with learning, I just don't know where all the characters and special nuances go. 

Object = MQL_SQL__c
Required Fields = Reject_Reason__c & Reject_Reason_Notes__c
Field that tracks the approval status = SAL_Approval_Status__c

Let me know if anything else is needed! Thank you!

Provided base code:
for(Object cr : Trigger.New)
    {
        String oldStatus=Trigger.oldMap.get(cr.Id).Status__c;
        if(cr.Status__c==CR_STATUS_APPROVED && oldStatus!=CR_STATUS_APPROVED)
        {
            // Effective Date is required if approved

            if(cr.effective_date==null) 
            {

                isValid = false;
                cr.addError('You must supply an effective date in order to approve the object.);
            }
            
My attempt at updating:  
for(MQL_SQL__c cr : Trigger.Rejection)
    {
        String oldStatus=Trigger.oldMap.get(cr.Id).SAL_Approval_Status__c;
        if(cr.SAL_Approval_Status__c==CR_STATUS_APPROVED && oldSAL_Approval_Status__c!=CR_STATUS_APPROVED)
        {
            // Reject Reason and Reject Notes are required if rejected

            if(cr.Reject_Reason__c==null) &&
            if(cr.Reject_Reason_Notes__c==null) 
            {

                isValid = false;
                cr.addError('Reject Reason and Reject Notes must be completed prior to Rejecting the SQL.);
            }            
When a contact attends seminars first time, an email should be sent . Same contact attending seminar within 60 days from intial email sent, no email needs to sent out. After 60 days , if same contact attended new seminar , send a new email. 
Seminar(Custom object) is a related list under contact . 
I think flow trigger/apex trigger is the way to go in comparing date of last email sent . But i am completely new to flow triggers. Can anyone please assist.
Fields avaliable in Seminar object 
Seminar_Status__c     Picklist
Contact__c                  Lookup(Contact)
Lead__c                       Lookup(Lead)

Criteria: Seminar Status= "Attended" and Contact<>NULL

Thank you 
Hi,
I want to e able to save a record(Custom) and also it should post a message to the user based on the criteria. I want to do this by customizing the standard Save button on the lightning Page. Any help on this would be appreciated.
1. Create a Formula Field named Domain on Contact Object, This should give me the Domain from Email Field on Contact Object. For Example: - If I save the Contact with Email as testuser@gmail.com, then formula field of Domain should have value “gmail”
2. Add a text Field at Account Level named as Contact Unique Domains
3. Create a trigger on Contact, Which handles Insert / Update / Delete / Undelete scenario. Trigger should get the Account Id from the Contact and then read all the related contacts from that Account and then Store the unique domains to the Account Level. For Example If I have below 3 contacts
Email - testuser1@gmail.com and Domain - gmail
Email - testuser2@yahoo.com and Domain as yahoo
Email - testuser3@gmail.com and Domain as gmail
So there are two unique domain gmail and yahoo, hence my Account text field will be populated with value gmail;yahoo
Hi, 

I have a String variable in my controller call ChildQuery. I want to pass a value to the string variable from Visualforce page without any javascript or button. How can that be possible? This value needs to be hidden and auto assign as soon as the visualforce page is opened.  

//set the value of Childquery to "write some string value here like ABCD"  without calling <script></script>
// maybe using these tags below? 

<!-- apex:inputHidden  / -->
<!-- apex:param  / -->
<!-- apex:variable / -->

This is what my class would look like. I'm writing a generic class which would be used by many many different visualforce page. So cannot set the value of the variavle in the controller. It has to pass through the visualforce page so I can throw any page and just call this controller class. 
Class sObject {

public string ChildQuery {get; set;}

    public sObjectController(ApexPages.StandardController controller){
      
        system.debug('THIS IS THE VALUE I'M GETTING:' + ChildQuery);

    }

}



 
Hi All,
As of now, Case page layout has Product Pick list, and we can select only one Product and it mainted by Pick List Values.
What I am looking is that, When we create a Case, we should able to select Multiple Products to that Case. How we can achieve this?.

Do we need to create a Junction Object between Cases and Product?.
I think Junction Object is not going to support for Product as Product Standard object is going to be Detail Side of Junction Object, which is not supported by Salesforce.

Please correct me if I am wrong.
Also, please suggest me an alternative methods.

Thanks,
Naren
  • August 14, 2019
  • Like
  • 1

I randomly was trying a split today on a '*' field and got the following error:

 

System.StringException: Invalid regex: Dangling meta character '*' near index 0 * ^

 

Out of curiosity, I tried to split on '+' and got the same error.  

 

This is easily reproducible for me by running the following code in the execute anonymous window - can anyone else  confirm?

string sString = 'someStuff'; string[] splitted = sString.split('*');