+ Start a Discussion
Rajat Bhatt 4Rajat Bhatt 4 
Hi,
I am new to salesforce and i am facing an issue my Trigger is not working properly.
I want the trigger to check whether the all Shipping Address field is filled or not , and if not the display the error message.
Any help will be appreciated.
Thanks.
trigger shippingAddress on Account (before insert,before update)
{

    List<Account> accList=new List<Account>();
    
    for(account accObject:trigger.new)
    {
        if(accObject.ShippingStreet !=null && accObject.ShippingCity!=null &&
           accObject.ShippingState!=null && accObject.ShippingPostalCode!=null && 
           accObject.ShippingCountry!=null)
        {
           accList.add(accObject);
        
        }
        
        else
        {
        
            accObject.addError('All Shipping Fields are required');
            
        }

    }
    
    insert accList;
}

 
Best Answer chosen by Rajat Bhatt 4
Ajay K DubediAjay K Dubedi
Hi Rajat,

Hi have done some small changes to your trigger. Hope this will work for you.

trigger shippingAddress on Account (after insert,after update)
{
    try{
    List<Account> accList=new List<Account>();
    
    for(account accObject:trigger.new)
    {
        if(accObject.ShippingStreet ==null || accObject.ShippingCity ==null ||
           accObject.ShippingState ==null || accObject.ShippingPostalCode==null || 
           accObject.ShippingCountry==null)
        {
           
        accObject.addError('All Shipping Fields are required');
        }
        
        else
        {
        
            accList.add(accObject);
            
        }

    }
    
    insert accList;
    }catch(Exception exp){
        system.debug('The following exception has occurred ' + exp.getMessage() + ' at line no ' + exp.getLineNumber());
    }
}

Thank you
Ajay Dubedi
Sneha KathavateSneha Kathavate 
Hi All,

I am relatively new to Apex coding. I have written a class which is giving the error "Missing return statement required return type: Boolean". Could you plz  help me resolve this .

public class CC_JobBoardApp_checkstatus {
    @AuraEnabled
    public static Boolean checkstatus()
    {
        Set<Id> jobid = new Set<Id>() ;
            for(TR1__Job_Board_Application__c jba : 
                [SELECT TR1__Status__c,TR1__Job__c,Job_Id__c    
                 from TR1__Job_Board_Application__c 
                 where Id in :JobId
                 LIMIT 1])
            if(jba.TR1__Status__c=='Rejected')
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}


The class checks if the status of the job application is rejected. If it is rejected, then returns true else returns false. 
Best Answer chosen by Sneha Kathavate
Ajay K DubediAjay K Dubedi
Hi Sneha,

You can do it in the following way. Hope this works for you.


public class CC_JobBoardApp_checkstatus {

    @AuraEnabled
    public static Boolean checkstatus()
    {
    public boolean isRejected = false;
        Set<Id> jobid = new Set<Id>() ;
            for(TR1__Job_Board_Application__c jba : 
                [SELECT TR1__Status__c,TR1__Job__c,Job_Id__c    
                 from TR1__Job_Board_Application__c 
                 where Id in :JobId
                 LIMIT 1])
            if(jba.TR1__Status__c=='Rejected')
        {
            isRejected = true;
        }
       return isRejected;
    }
}

Thank You
Ajay Dubedi
Ravi Dutt SharmaRavi Dutt Sharma 
Hi,

Need inputs on how to parse below string and extract all the relevant information such as Source, Name etc.

Source: Web Visitor 
Name: Ravi Sharma 
Age of primary applicant: 9 


Email: test@yahoo.com 
Phone: 1234567 
Address: 10th Street 
City: Woodstock 
State: GA 
Comments: Test Comments 
Best Answer chosen by Ravi Dutt Sharma
Suraj GharatSuraj Gharat
You may use regex here, as below.
 
// You input. I was not sure about line break character, but similar logic can be used
string input = 'Source: Web Visitor \n'+
'Name: Ravi Sharma \n'+
'Age of primary applicant: 9 \n\n\n'+
'Email: test@yahoo.com \n'+
'Phone: 1234567 \n'+
'Address: 10th Street ';

// split whole input into lines
string[] lines = input.split('[\n]+');

string regex = '([^:]+):([^:]+)';

Pattern MyPattern = Pattern.compile(regex);

// Apply regex to every line
for(string inputLine : lines){
	matcher myMatcher = myPattern.matcher(inputLine.trim());
	if(myMatcher.matches() && myMatcher.hitEnd() && myMatcher.groupCount() == 2){
		system.debug('**** Match :'+myMatcher.group(1).trim() + '=>'+myMatcher.group(2).trim());
	}
	else{
		system.debug('No match: line :'+ inputLine);
	}
}

Hope this helps.
Nasir SiddiquiNasir Siddiqui 
Hi,

Can someone please  advise what permissions are needed to enable the edit functionality on Email Alert for a user other then system admin

Thanks,
Nasir

 
Best Answer chosen by Nasir Siddiqui
Raj VakatiRaj Vakati
Customize application permission is required 
LinThawLinThaw 
Hi there, 

I got following error on step 3.

A Volunteer Shift Worker record created for another user is not in their approval queue, or it does not have the correct status automatically assigned.

Anyone passed this step?

Thanks
LinThaw
Best Answer chosen by LinThaw
KruzKruz
Hi LinThaw,

The problem is in process builder. please check process builder.

Initial criteria (1st Block) for process builder is: Status does not equal to Confirm and completed then and then your approval process will fire after that in 2nd block criteria is IsShiftVolunter = true then action should be field update (Update Status to 'Confirm').

I hope you got the answer. and if you have any problem to pass this challenge feel free to contact me.
Harjinder AhluwaliaHarjinder Ahluwalia 
Hi 
I am calling a datatable from the action button on the detail page, the pop window width is very less, i want to increase it to.
Please complete full procedure how can i fix this problem.
Thanks
Best Answer chosen by Harjinder Ahluwalia
Alain CabonAlain Cabon
Hi, 

1) Create this static resource: popupCSS
 
.slds-modal__container{
    max-width: 70rem !important;
    width:80% !important;
}

2) Use this new static resource with <lng:require> at the beginning of your component
 
<aura:component controller="MyCrtrl"implements="force:lightningQuickAction,force:appHostable,force:hasRecordId,force:hasSObjectName">
   <ltng:require styles="{!$Resource.popupCSS}" />
Pawan Kumar 32Pawan Kumar 32 
Hello All,
I am stuck in below trailhead chanllange
Create a Visualforce page that displays the first name of the logged-in user.
  • The page must be named 'DisplayUserInfo'.
  • The displayed user information must be generated dynamically from the logged-in user.
Here below is my code. Please help me to find the solution.
<apex:page>
{!$User.FirstName } {!$User.LastName } ({!$User.Username })
</apex:page>
Best Answer chosen by Pawan Kumar 32
sfdcdevsfdcdev
Log out from the account which you're using to check the challenge and log in again to recheck the challenge.
Abderrahim LahrachAbderrahim Lahrach 
Hi guys,
i recently completed 100% of the admin beginner trail, but salesforce still didn't add it up to my trail's count on my profile, what should i do? thank you
Best Answer chosen by Abderrahim Lahrach
Abderrahim LahrachAbderrahim Lahrach
Navin Prasad: Just give it a bit of time, and it'll add up, that's what i did :)
John LayJohn Lay 
Hello... I've stared at this until I'm cross-eyed.
I can't seem to get past this challenge.
My current issue is:
Challenge Not yet complete... here's what's wrong:
The BoatSearchResults component must define a selected attribute on the BoatTile component that passes a boolean value using the ternary operator.
I'm using a ternary operator as I would expect.

BoatSearchResults.cmp
.
.
.
    <aura:attribute name="boats" type="Boat__c[]"/>
.
    <aura:attribute name="selectedBoatId" type="Id" />
.
.
.

    <aura:set attribute="else">
			<lightning:layout horizontalAlign="spread" multipleRows="true">
				<aura:iteration var="boat" items="{!v.boats}">
            		<lightning:layoutitem >
                		<c:BoatTile boat="{!boat}" selected="{! boat.Id == selectedBoatId ? 'true' : 'false' }"/>
            		</lightning:layoutitem>
        		</aura:iteration>
    		</lightning:layout>
    </aura:set>
.
.
.
I've tried several attempts at writing and rewriting this but the challenge does not pass.

BoatTile
 
<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="boat" type="Boat__c"/>
    <aura:attribute name="selected" type="Boolean" default="false" />
    
    <aura:registerEvent name="BoatSelect" type="c:BoatSelect"/>

	<lightning:button name="{!v.boat.Id}" class="{! v.selected == true ? 'tile selected' : 'tile' }" onclick="{!c.onBoatClick}" >
	<div style="{!'background-image: url(\'' + v.boat.Picture__c + '\')'}" class="innertile">
  		<div class="lower-third">
   			<h1 class="slds-truncate">{!v.boat.Contact__r.Name }</h1>
  		</div>
	</div>
	</lightning:button>
</aura:component>

Any input would be appreciated.
John.




 
Best Answer chosen by John Lay
John LayJohn Lay
Ok...like I said, I was going cross-eyed. I found my mistake. Simple once I got some sleep and reviewed my code.
I was missing the v. on v.selectedBoatId in the expression.
selected="{! boat.Id == v.selectedBoatId ? true : false }"

 
Rajat Bhatt 4Rajat Bhatt 4 
Hi, I am new to salesforce and i am facing a problem in retrieving an account name.
I have a String which contains the account id , and i want to fetch the account name  using SOQL so that i can store it in the field?

Thanks in advance.
Best Answer chosen by Rajat Bhatt 4
Raj VakatiRaj Vakati
You need to user SOSL libe below 

Account acc  = [Select Id ,Name from Account where id=:yourIDString ] 

Or

Account acc  = [Select Id ,Name from Account where id='record id '] ;