+ Start a Discussion
Shaolin MasterShaolin Master 
I want to know how to parse the URL params from a get request
/services/apexrest/Endpoint/?subject=test&status=active&priority=1&origin=?subject=test&status=active&priority=1
I want to parse the url params in the class below
@HttpGet
    global static void getStatus() {
        RestRequest request = RestContext.request;
        System.debug(request.requestURI); 
        
    }

Please help!
Best Answer chosen by Shaolin Master
Maharajan CMaharajan C
Hi,

You have to write like below to parse the request:
@HttpGet
global static void getStatus() {
    RestRequest req = RestContext.request;
    String subject = req.params.get('subject');
    String status = req.params.get('status');
    String priority = req.params.get('priority');
    String origin = req.params.get('origin');
    
    system.debug('subject --> ' + subject  + ' status --> ' + status + 'priority --> ' + priority + 'origin --> ' + origin);

}

Thanks,
Maharajan.C
rima khanrima khan 
Hi!
I registered with trailhead.
I’m an SDR looking to expand my Salesforce skill set. Let’s pretend I have none. Particularly looking for the basics around reporting, and any other trails that may be beneficial to spend some time with.
My goal is to have a competent understanding of SF to build my sales as I enter a closing role and the relevant tools in SF that will help me gain an advantage.
Thanks in advance!
Best Answer chosen by rima khan
manasa udupimanasa udupi
Hi Rima,

Below are few trailhead links, hope it helps:)

https://trailhead.salesforce.com/en/content/learn/modules/sales_admin_sales_reports_for_lex
https://trailhead.salesforce.com/en/content/learn/modules/sales-activity-analysis
YiQin HeYiQin He 
Hi, 

I created a lightning component as a quick action button. In the component, I have a cancel button that I want it closed when user clicks.
User-added image

But the problem is that I cannot find any document explain how to close the modal dialog. This is the ui code:
<aura:component controller="ContactController" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" >
    <style>
        .changeRecordTypeRow {
        margin-top: 1.5rem;
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 0;
        }
        
        .changeRecordTypeLeftColumn {
        float: left;
        text-align: right;
        padding-right: 1.5rem;
        width: 35%;
        font-size: .8125rem;
        color: rgb(84, 105, 141);
        }
        
        .changeRecordTypeRightColumn {
        float: right;
        text-align: left;
        width: 65%;
        }
        
        .modal-body
        {
        	height:auto !important;
        	padding:0;
        }
        
        .forceChatterLightningComponent .bodyWrapper{height:100%;width:100%;padding:0;box-sizing:border-box}
    </style>
    <div class="modal-header slds-modal__header">
        <h2 class="title slds-text-heading--medium" >Change Contact Type</h2>
    </div>
    <div class="scrollable slds-modal__content slds-p-around--medium">
        <div class="changeRecordTypeRow">
            <fieldset class="slds-form-element">
                <div class="changeRecordTypeLeftColumn">
                    <legend class="form-element__legend slds-form-element__label">Select a record type</legend>
                </div>
                <div class="changeRecordTypeRightColumn slds-form-element__control">

                    <span class="slds-radio">
                        <input type="radio" id="radio_PrimaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_PrimaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Primary Contact</span>
                        </label>
                    </span>
                    <span class="slds-radio">
                        <input type="radio" id="radio_SecondaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_SecondaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Secondary Contact</span>
                        </label>
                    </span>
                </div>
            </fieldset>
        </div>
	</div>
    <div class="modal-footer slds-modal__footer">
    	<div class="forceChangeRecordTypeFooter">
        	<button type="button" class="slds-button slds-button--neutral .slds-modal__close" aura:id="btnCancel" >
            	Cancel
            </button>
            <button type="button" class="slds-button slds-button--brand" aura:id="btnSave">
            	Save
            </button>
        </div>
    </div>
</aura:component>
Does anyone have similar experience? Thanks in advance.
Best Answer chosen by YiQin He
YiQin HeYiQin He
Hi Karthik,

Thanks for the reply. I've already found the solution.
Call this method $A.get("e.force:closeQuickAction").fire() will close the modal dialog.

Yiqin
Tony Montana 6Tony Montana 6 
if(requestId != null) {
        
               List<GLOBAL_Request__c> requestObj = [select id, business_unit__c, recordtype.developername from GLOBAL_Request__c where id=:requestId AND recordtype.developername = 'Send_Survey' Limit 1];
            if (requestObj != null){        
            List<User> usrRec =[select id, NT_Login_Name__c from User where id=:UserInfo.getUserId() And NT_Login_Name__c != null Limit 1];
                    if(usrRec != null){
                    List<Contact> contactRec = [select id, contactRec.NT_Login_Name__c from contact where NT_Login_Name__c=:usrRec.NT_Login_Name__c ORDER by LastModifiedDate DESC Limit 1];         
                        if (contactRec != null){
                          List<Participant__c> participantRec = [select Id, Name,Survey_Taken_Date__c from Participant__c where Participant__c=:contactRec.Id AND Request__c=:requestObj.Id ORDER by CreatedDate DESC LIMIT 1];
                            if(participantRec != null && participantRec.Survey_Taken_Date__c == null){
                                ParticipantId = participantRec.Id;
                                contactId = contactRec.Id;
                                requestId = requestObj.Id;
                                Participant__c updateSurveyTakenDate = new Participant__c(id = ParticipantId, Survey_Taken_Date__c = System.now());            
                                       upsert updateSurveyTakenDate;  
                            } else if(participantRec != null && participantRec.Survey_Taken_Date__c != null){
                                Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.LABS_SF_You_have_already_taken_this_survey));
                                return false;
                            } else {
                                Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.LABS_SF_Participant_Not_Part_Of_This_Pool));                    
                                 return false;
                            }
                        }
                    }
            }
        }
  
And I am getting the following error.


1.Variable does not exist: NT_Login_Name__c
2.Variable does not exist: Id
3.Variable does not exist: Survey_Taken_Date__c
4.Variable does not exist: Id
5.Variable does not exist: Survey_Taken_Date__c

Will appreciate your help.

Thanks,
TM
      
Best Answer chosen by Tony Montana 6
Maharajan CMaharajan C
Hi Tony,

Instead of Null check use the IsEmpty function to check the list has data or not:

IsEmpty function will solve the List index out of bounds: 0 issue.
 
if(requestId != null) {

    List<GLOBAL_Request__c> requestObj = [select id, business_unit__c, recordtype.developername from GLOBAL_Request__c where id=:requestId AND recordtype.developername = 'Send_Survey' Limit 1];
	if (!requestObj.isEmpty()){        
	List<User> usrRec =[select id, NT_Login_Name__c from User where id=:UserInfo.getUserId() And NT_Login_Name__c != null Limit 1];
			if(!usrRec.isEmpty()){
			List<Contact> contactRec = [select id, contactRec.NT_Login_Name__c from contact where NT_Login_Name__c=:usrRec[0].NT_Login_Name__c ORDER by LastModifiedDate DESC Limit 1];         
				if (!contactRec.isEmpty()){
				  List<Participant__c> participantRec = [select Id, Name,Survey_Taken_Date__c from Participant__c where Participant__c=:contactRec[0].Id AND Request__c=:requestObj[0].Id ORDER by CreatedDate DESC LIMIT 1];
					if(!participantRec.isEmpty() && participantRec[0].Survey_Taken_Date__c == null){
						ParticipantId = participantRec[0].Id;
						contactId = contactRec[0].Id;
						requestId = requestObj[0].Id;
						Participant__c updateSurveyTakenDate = new Participant__c(id = ParticipantId, Survey_Taken_Date__c = System.now());            
							   upsert updateSurveyTakenDate;  
					} else if(!participantRec.isEmpty() && participantRec[0].Survey_Taken_Date__c != null){
						Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.LABS_SF_You_have_already_taken_this_survey));
						return false;
					} else {
						Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, System.Label.LABS_SF_Participant_Not_Part_Of_This_Pool));                    
						 return false;
					}
				}
			}
	}
}

Thanks,
Maharajan.C
NewBee21NewBee21 
I am getting this error while previewing visualforce page. ==> Error: Unknown property 'AccountStandardController.con'


Visualforce page:

<apex:page standardController="Account" extensions="ExtensionController5">
<apex:form >
<apex:pageBlock title="Account Information" id="account"> <apex:pageBlocksection>
<apex:inputField value="{!con.accountId}"/>
<apex:actionsupport event="onchange" action="{!accountselected}" rerender="account,msgs" status="stat"/>
</apex:pageBlockSection
</apex:pageBlock>
</apex:form>
</apex:page>


Controller:

public class ExtensionController5{ private ApexPages.StandardController Stdctrl;
public ExtensionController5(ApexPages.StandardController controller){ Stdctrl=controller; }
public void AccountSelected() { contact con=(contact) StdCtrl.getRecord();
if (!string.IsBlank(con.accountid))
{ con.account=[select Name,Phone from Account where id=:con.accountid]; }
else { con.account=null; } } }
Best Answer chosen by NewBee21
Suraj Tripathi 47Suraj Tripathi 47
Hey NewBee,
Please consider given code below -
Apex Class -

public class DisplayContactOnAccountSelController {

    public list<AccountContactWrapper> lstAccountContactWrapper { get; set; }
    public list<AccountContactWrapper> lstSelectedAccountContactWrapper { get; set; }
    public list<account> selectedAccounts{get;set;}   

    public DisplayContactOnAccountSelController () {
        lstSelectedAccountContactWrapper = new list<AccountContactWrapper>();
        if(lstAccountContactWrapper == null) {
            lstAccountContactWrapper = new list<AccountContactWrapper>();
            for(account a:[select id,name,(select id,name from contacts) from account limit 10]) {
                lstAccountContactWrapper.add(new AccountContactWrapper(a));
            }
        }
    }
 
    public void ProcessSelected() {
        lstSelectedAccountContactWrapper =new list<AccountContactWrapper>();
        selectedAccounts =new list<Account>();
        for(AccountContactWrapper wrapobj:lstAccountContactWrapper){
            if(wrapobj.isSelected==true) {
                selectedAccounts.add(wrapobj.acc);
            } 
        }
       
        for(Account acc:[select id,name,(select id,name from contacts) from account where id in:selectedAccounts]) {
            lstSelectedAccountContactWrapper.add(new AccountContactWrapper(acc)); 
        }
             
    }
    public class AccountContactWrapper {
 
        public Account acc {get;set;}
        public boolean isSelected {get;set;}
   
        public AccountContactWrapper(account a) {
            acc = a;
            isselected=false;
        }
    }
}

Visualforce Page -
<apex:page sidebar="false" controller="DisplayContactOnAccountSelController">
<apex:form >
    <apex:pageBlock id="AccountContactBlock">
        <apex:pageBlockSection columns="2">
        <apex:pageBlockTable value="{!lstAccountContactWrapper}" var="acc" id="AccountSection">
            <apex:column >
                <apex:inputCheckbox value="{!acc.isSelected}" id="InputId"/>
            </apex:column>
            <apex:column value="{!acc.acc.name}"/>
        </apex:pageBlockTable>
        <apex:pageBlockTable value="{!lstSelectedAccountContactWrapper}" var="acc" id="contactsSection" rendered="{!IF(lstSelectedAccountContactWrapper.size > 0,true,false)}">>
            <apex:column headerValue="Account and Its Related Contacts">
                <apex:pageBlockTable value="{!acc.acc.contacts}" var="con">
                    <apex:facet name="header">{!acc.acc.Name}</apex:facet>
                    <apex:column value="{!con.name}" headerValue="Contact Name"/>
                </apex:pageBlockTable>
            </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
        <apex:pageBlockButtons location="bottom">
          <apex:commandButton action="{!ProcessSelected}" value="Show Account and its Contacts" reRender="AccountContactBlock,contactsSection"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>

</apex:page>

Here is the output
Please mark it as the best answer if it helps.
Thank you!
henry weasleyhenry weasley 

I cannot receive test emails for templates when I hit send they don't arrive
Best Answer chosen by henry weasley
henry weasleyhenry weasley

Hope that your day is off to an amazing start. Did you check the email address listed in the email field or User account? Second, please check your Deliverability settings by going to Setup>Setup>Type in the search bar Deliver and ensure that your Access Level settings is set to All Emails

my issue got solved!!

___________________________
 whatsapp web (https://openweb.vip/whatsapp-web/) 192.168.0.1 (https://19216801.onl/) routerlogin (https://routerlogin.uno/)

Sundeep Jaswal 7Sundeep Jaswal 7 
How to make a field required if a picklist value is true?
I need to have the field custom_terms__c required if Payment_terms__c picklist value equals 'custom.' 
AND(
 ISPICKVAL(Payment_Terms__c, "custom")
 ISBLANK(Custom_Terms__c)
)
Best Answer chosen by Sundeep Jaswal 7
AbhinavAbhinav (Salesforce Developers) 
Use below it should work
 
AND(
ISPICKVAL(Payment_Terms__c, "custom"),
ISBLANK(Text(Custom_Terms__c))
)

If it helps mark it as best answer.

Check below doc how to use ISBLANK for different scenario

https://help.salesforce.com/s/articleView?id=sf.customize_functions_i_z.htm&type=5

Thanks!
David BerroaDavid Berroa 
We have an online software platform where we managed our clients rental business. Each client is a broker and can potentiatlly have their own Salesforce product. Is there a cost for us to integrate with salesforce and then allow our client to associate with our integration via oauth to then sync our software and salesforce?

I'm specifically wondering for us the management software and not the client. I know the client will be paying salesforce for their products but for us to have an api integrations, do we need to pay anything for that access?
Best Answer chosen by David Berroa
AbhishekAbhishek (Salesforce Developers) 
David If your client is already paying for salesforce then you don't need to pay anything for integration.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Regards,
​​​​​​​Salesforce Support.
DeveloperSudDeveloperSud 
Hi All,

I was referring the salesforce documentation for lightning:input type="email" .There it is mentioned When multiple email is used, the email field expects a single email address or a comma-separated list of email addresses. Example, my@domain.com,your@domain.com with or without a space after the comma.Is it possible to use type="email" when there is a need to enter multiple email id.I have tried to enter multiple emails with comma separation but it is giving me error as "You have entered an invalid format.".
Best Answer chosen by DeveloperSud
sachinarorasfsachinarorasf
Hi,

Please use the below code.

Email:-

An input field for entering an email address. The email pattern is automatically validated during the blur event.

<lightning:input type="email" label="Email" name="email" value="abc@domain.com" multiple="true"/>

Valid email addresses include name@domain and name@domain.com. When multiple is used, the email field expects a single email address or a 
comma-separated list of email addresses. For example, my@domain.com,your@domain.com with or without a space after the comma.

Use the below link.
https://developer.salesforce.com/docs/component-library/bundle/lightning:input/documentation

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
www.sachinsf.com
Ankita dixitAnkita dixit 
Account - opportunities = lookup relationship

Suppose there is Account and we need to calculate how many new opportunities created in the month of September?

how to write SOQL and trigger? Please help !!
Best Answer chosen by Ankita dixit
CharuDuttCharuDutt
Hii Ankita
Try Below trigger
trigger SumAmountOpp on Opportunity (After Insert,After Update,After Delete) {
 List<Account> accList=new List<Account>();

    Set<Id> setAccIds = new Set<Id>();
    if(Trigger.isInsert){
         if(trigger.isAfter){
        for(Opportunity con : Trigger.new){
            if(con.AccountId != null){
            setAccIds.add(con.AccountId);
            	}
			}
		}
    } 
    system.debug('setAccIds ==> '+setAccIds);
    if(Trigger.isUpdate){
         if(trigger.isAfter){
        for(Opportunity con : Trigger.new){ 
            if(con.AccountId!=Trigger.oldMap.get(con.Id).AccountId){
               	setAccIds.add(con.AccountId);
                setAccIds.add(Trigger.oldMap.get(con.Id).AccountId);
            	}
			}        
        }
    }
    if(Trigger.isDelete){
        if(trigger.isAfter){
        for(Opportunity con : Trigger.old) { 
            if(con.AccountId != null){
            setAccIds.add(con.AccountId);
            	}
        	}
        }
    }    
    for(Account acc :[Select id,Total_Opprotunites__c ,(Select id,Name,CreatedDate  from Opportunities where CreatedDate = THIS_MONTH) from Account where Id in : setAccIds]){
			
        acc.Total_Opprotunites__c = Acc.Opportunities.size();
        acclist.add(acc);
        
    }
    if(acclist.size()>0){
        update accList;     
    }
    
}
Please Mark It As Best Answer If It Helps
Thank You!