+ Start a Discussion
Rohit TripathiRohit Tripathi 
I am getting error message while solving this challenge in Trailhead :

To complete this challenge, add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).Name the validation rule 'Contact must be in Account ZIP Code'.
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be inserted.
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)

Error Message is :  There was an unhandled exception. Please reference ID: HKIZNLVZ. Error: Trailhead::TrailheadTimeOut. Message: Trailhead.view: failed to get a 200 response. Made 3 attempts each resulting in a 403 or 500 failure for url challenges?key=%5B%22trailhead.challenge.validation_rules.en.us.192%22%5D.

I am not sure what went wrong here.
My Validation Rule is on Contact Object  :

  AND ( NOT(ISBLANK( Account.Name)),
( MailingPostalCode <> Account.ShippingPostalCode))

Can anyone please help with this.
Best Answer chosen by Rohit Tripathi
Amit Chaudhary 8Amit Chaudhary 8
Please try below valudation rule
AND(
NOT(ISBLANK(AccountId)),
MailingPostalCode != Account.ShippingPostalCode
)
i Used same and got all points in Trailhead challenge


 
Harsha s 56Harsha s 56 
HI all
   Im new to salesforce . i want to write  a trigger  when ever Email/ phone of the account  is updated ,all the contact email should be same. any one help me to solve 

Thank you
Harsha
Best Answer chosen by Harsha s 56
sunny522sunny522
trigger SameEmailOnAllContacts on Account (after update) {
    Set<Id> setAccountId = new Set<Id>();
    for(Account acc:trigger.new) {
        if(Trigger.oldMap.get(acc.ID).Email__c != acc.Email__c || Trigger.oldMap.get(acc.ID).phone != acc.phone) {
            setAccountId.add(acc.id);
        }
    }
    List<Contact> lstContact = new List<Contact>();
    for(Account acc:[Select id,Email__c,(select id,Email from Contacts) from Account where Id in:setAccountId]) {
        for(Contact con:acc.contacts) {
            if(con.Email != acc.Email__c) {
                con.Email = acc.Email__c;
                lstContact.add(con);
            }
        }
    }
    if(lstContact.size() >0) {
        update lstContact;
    }
}

Please use this trigger code Harsha .
Basil DobekBasil Dobek 
Hi, I'm trying to create a new empty project using the Salesforce CLI and I receive the message "ERROR running force:project:create  Cannot read property 'create' of undefined".    Does anyone know what might be causing this or how to further troubleshoot it? 

The command I'm entering in the terminal is "sfdx force:project:create --projectname VSCodeQuickStart".   I've tried "sfdx force:project:create --projectname VSCodeQuickStart --manifest" as well.


Thank you


 
Best Answer chosen by Basil Dobek
Khan AnasKhan Anas (Salesforce Developers) 
Hi Basil,

Greetings to you!

Please make sure you are using the latest version of salesforcedx. Try to update the CLI
sfdx update

If the problem still persists, uninstall the salesforcedx and reinstall it.

I hope it helps you.

Kindly 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. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
shiv prakashshiv prakash 
Hi guys, 

 I want to enable API but don't find option to enable API in my trial account.

please tell me can i enable api to trial account.
Best Answer chosen by shiv prakash
kiranmutturukiranmutturu
every profile is having an option API Enabled  -> Access any Salesforce.com API.. This you need to check inorder to make use of the any salesforce API.
Angela Ramirez 1Angela Ramirez 1 
I properly installed CLI. In a command window, I enter:

sfdx force:auth:web:login -d -a DevHub

in order to log in to the trial Dev Hub that I created. The aforementioned command opens the Salesforce login page in the web browser, so I log in using my Developer Hub Trial Org credentials and click Allow. After that, web browser show me an error: "This site can't be reached. localhost took too long to respond".

This is the URL that Salesforce use after I authenticate in the browser: http://localhost:1717/OauthRedirect?code=aPrxbOND3gL_2LbSR7rKPdvD0XBVk2YpErl3pphY2f3xvZ1wf5SSPJByDleRLPMtzCQWnNGAdg%3D%3D&state=f2f8254fac23

I don't know what happen.

User-added image

User-added image

User-added image
Best Answer chosen by Angela Ramirez 1
Abdul KhatriAbdul Khatri
OK Lets dry below and see if it works

Authorize the CLI to work with your DevHub by typing:
sfdx force:auth:web:login -h
This will automatically open your browser and prompt you to login to the dev hub. Use the credentials that you used to create the Salesforce DX authorized dev hub. Click Allow when the Oauth Flow prompts you to.

Once you’ve gone through this authorization process you can set up an alias using the following command
sfdx force:auth:web:login -d -a DevHub
You should see something like:
Successfully authorized <your-username> with org id 00B1I000000L9r3UCY
You may now close the browser
Now you should be able to open the dev hub using this
sfdx force:org:open -u DevHub
Let me know if this works
Sean M 3Sean M 3 
Good morning,

I have created a lightning component which runs a visual flow creating an Event record.

When the flow finishes I would like the page to be redirected to the created Event.

I have found a help topic with some example code but it would be great if someone could explain it ie. where would I add the created record id variable in my flow in this code so that it redirects?

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_using_flow_onfinish.htm
 
handleStatusChange : function (component, event) {
   if(event.getParam("status") === "FINISHED") {
      var outputVariables = event.getParam("outputVariables");
      var outputVar;
      for(var i = 0; i < outputVariables.length; i++) {
         outputVar = outputVariables[i];
         if(outputVar.name === "redirect") {
            var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
               "recordId": outputVar.value,
               "isredirect": "true"
            });
            urlEvent.fire();
         }
      }
   }
}

Thank you
Best Answer chosen by Sean M 3
Raj VakatiRaj Vakati
Change your code as below
 
handleStatusChange : function (component, event) {
   if(event.getParam("status") === "FINISHED") {
      var outputVariables = event.getParam("outputVariables");
      var outputVar;
      for(var i = 0; i < outputVariables.length; i++) {
         outputVar = outputVariables[i];
         if(outputVar.name === "CreatedCaseId​") {
//The above line to match your flow var
            var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
               "recordId": outputVar.value,
               "isredirect": "true"
            });
            urlEvent.fire();
         }
      }
   }
}

 
RajanJasujaRajanJasuja 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11">

Hi,


Is there any way to get current date and time as per the logged in user time zone in apex?

I used System.now(), but its returning as per GMT time zone. I need it as per the user time zone.Like if logged in use time zone is Singapore time zone then it should return current time and date  as per the Singapore time zone which is GMT+8,  not as per the GMT time zone. 


Thanks and Regards,

Rajan Jasuja


Best Answer chosen by Admin (Salesforce Developers) 
JPSeaburyJPSeabury
You can manipulate the date using the "format" instance method.  The following Apex method takes the current datetime, and displays it in "long date" format:
 
Code:
public class MaintCalendar {

  String LongDate = ' ';

  // Init cLongDate with the current Datetime in long date format    
  public String getLongDate() {
    Datetime cDT = System.now();
    LongDate = cDT.format('EEEE, MMMM d, yyyy');
    return LongDate;
  }

}

 

The first line in the getlongDate method initializes the ‘cDT’ variable with the current datetime.  The second line uses the “format” instance method to set a global string variable “LongDate”, using the following SimpleDateFormat string: ‘EEEE, MMMM d, YYYY’  The four letters indicate that the Day, Month and Year should be spelled out in full (non-abbreviated) form. 

 

With the Java Class SimpleDateFormat instance method, you can display the date in any format that you want.  Read more about Java Class SimpleDateFormat on the Java website:  http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html

 

The code (and the VF page output) is displayed below.

 



Message Edited by JPSeabury on 09-16-2008 06:59 AM
Malhar Patel PatelMalhar Patel Patel 
For life of me I can't figure out what this exercise is asking to do.  I was able to modify other reports but this particualr R&D report, Temperature to kWh Research, I'm not able to do.  Error is keep saying, "We can’t find the additional analysis by model being performed on the 'Temperature to kWh Research' report. Remember that you can organize data horizontally and vertically at the same time."

User-added image


 
Best Answer chosen by Malhar Patel Patel
John McGuigan 28John McGuigan 28
Needs to be a Matrix report, with horizontal bars.
Amidou CisseAmidou Cisse 
User-added image
Hello everyone, I hope you are well.
I have this array of data to develop by lightning component, this table allows me to show some data from my campaign as you can see below. If someone has already developed a simulare lightning component, I would like to have their code as a model to adapt my table.

Thank you in advance.
Best Answer chosen by Amidou Cisse
Amidou CisseAmidou Cisse
Thanks gays, my problème is solved, it work.

User-added image

 
// Controller Apex


public with sharing class CampaignController {
    
    @AuraEnabled
    public static List<Campaign> getCampaign(Id CampaignId) {
        return [SELECT Id, cel_ext_id_campaign__c, Name, cel_category__c, cel_SubCatergory__c, IsActive, cel_Countries__c, BudgetedCost, StartDate, EndDate, cel_Format__c, cel_MenWomen__c,
                NumberSent, cel_Reason__c, NumberOfResponses,cel_Stores__c, cel_AmountTotal__c, cel_TotalConfirmed__c, cel_TotalDirectSales__c, cel_TotalInvited__c,
                cel_TotalPurchasing__c, cel_TotalSales__c, cel_TotalShowUp__c, cel_Total__c, cel_BudgetEuro__c, cel_SalesTargetResWDeposit__c, cel_SalesTargetResWODeposit__c,
                cel_TotalSLG__c, cel_TotalRTW__c, cel_TotalShoes__c, cel_TotalBags__c, cel_TotalACC__c
                FROM Campaign where Id=:CampaignId];
    }   
    @AuraEnabled
    public static Campaign saveCampaign(Campaign campaign) {
        upsert campaign;
        return campaign;
    }     
}
 
// Componant 1 


<aura:component controller="CampaignController" implements="lightning:isUrlAddressable,force:hasSObjectName,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">                                                           
	<aura:attribute name="recordId" type="String" />
    <aura:attribute name="campaigns" type="Campaign[]"/>     
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>  
        <lightning:layoutItem >
            <c:CEL_CampaignDetailList campaigns="{!v.campaigns}"/>
        </lightning:layoutItem>
</aura:component>
 
//componant 2


<aura:component controller="CampaignController" access="global" >
   <aura:attribute name="recordId" type="String" />
   <aura:attribute name="campaigns" type="Campaign[]"/>
	 <lightning:card title="">
        <p class="slds-p-horizontal--small">
            <aura:iteration items="{!v.campaigns}" var="campaign">
                <c:CEL_CampaignItem campaign="{!campaign}"/>
            </aura:iteration>
        </p>
    </lightning:card>
</aura:component>
 
// Componant 3

<aura:component controller="CampaignController" access="global"> 
   <aura:attribute name="recordId" type="String" />
   <aura:attribute name="campaign" type="Campaign[]"/>
   
    <div class=" slds-grid slds-grid_vertical " style="height:auto width:auto;" >    
         <h1 style="font-weight: bold; color:white; text-align:center;"> Campaign Details </h1> 
        	<table class="slds-table slds-table_bordered slds-table_cell-buffer">            
                     <tr>                     
                      <td data-label="Category">
                        <div class="slds-truncate" title="Category">Category</div>
                      </td>
                      <td>
                        <div class="slds-truncate" > 
                            <lightning:formattedText value="{!v.campaign.cel_Category__c}" style="string"/>
                        </div>
                      </td>
                      <td data-label="Invited">
                        <div class="slds-truncate" title="Invited">Invited</div>
                      </td>
                      <td>
                        <div class="slds-truncate">                           
                           <lightning:formattedNumber value="{!v.campaign.cel_TotalInvited__c}"/></div>
                      </td>
                      <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                      <td >
                        <div class="slds-truncate" title="tot_pot_sales">Total Direct Sales</div>
                      </td>                       
                      <td>
                        <div class="slds-truncate">
                           <lightning:formattedNumber value="{!v.campaign.cel_TotalDirectSales__c}" style="currency"/>
                        </div>
                      </td>
                      <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                      <td data-label="Clienteling_rate">
                        <div class="slds-truncate" title="Clienteling_rate">Total Confirmed</div>
                      </td>                        
                      <td data-label="Clienteling_rate_val">
                        	<div class="slds-truncate" >
                               <lightning:formattedNumber value="{!v.campaign.cel_TotalConfirmed__c}"/>
                            </div>
                      </td>
                      <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                    </tr>              
                <!--*********************** -->
                    <tr>  
                      <td data-label="Sub Category">
                        <div class="slds-truncate" title="Bub Category">Sub Category</div>
                      </td>
                      <td>
                        <div class="slds-truncate" > 
                            <lightning:formattedText value="{!v.campaign.cel_SubCatergory__c}" style="string"/>
                        </div>
                      </td>
                      <td data-label="PERIOD">
                        <div class="slds-truncate" title="Period">Star date</div>
                      </td>
                      <td data-label="Period_Plage">
                        <div class="slds-truncate" title="Period_Plage">
                            <lightning:formattedDateTime value="{!v.campaign.StartDate}" style="Date"/>
                        </div>
                      </td> 
                      <td data-label="emp">
                      </td>
                      <td >
                        <div class="slds-truncate" title="Period">End date</div>
                      </td>
                      <td data-label="Period_Plage">
                        <div class="slds-truncate" title="Period_Plage">
                            <lightning:formattedDateTime value="{!v.campaign.EndDate}" style="Date"/>
                        </div>
                      </td>
                      <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                      <td data-label="Contacted">
                        <div class="slds-truncate" title="Contacted">Country</div>
                      </td>
                      <td data-label="Val_Contacted">
                        <div class="slds-truncate" title="Val_Contacted">
                         <lightning:formattedText value="{!v.campaign.cel_Countries__c}" style="string"/>
                        </div>
                      </td>    
                       <td data-label="Activation_rate_val">
                        	<div class="slds-truncate" title="Activation_rate_val"></div>
                      </td>
                      <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                    </tr>                          
                 <!-- ************** -->
                    <tr>                  
                      <td>
                        <div class="slds-truncate">Budget(€)</div>
                      </td>
                      <td >
                        <div class="slds-truncate">
                        	<lightning:formattedNumber value="{!v.campaign.cel_BudgetEuro__c}" style="currency"/>
                        </div>
                      </td>                      
                      <td data-label="Resa_whith_deposit">
                        <div class="slds-truncate" title="tot_pot_sales">Sales Target Res W Deposit</div>
                      </td>          
                      <td data-label="Resa_whith_deposit_amount">
                        <div class="slds-truncate" title="Resa_whith_deposit_amount">
                        	<lightning:formattedNumber value="{!v.campaign.cel_SalesTargetResWDeposit__c}" style="currency"/>  
                        </div>
                      </td>
                        <td data-label="Resa_whith_deposit_amount_percent">
                        <div class="slds-truncate" title="Resa_whith_deposit_amount_percent"></div>
                      </td>
                        <td data-label="Cross_selling_rate">
                        <div class="slds-truncate" title="Cross_selling_rate">Sales Target Res W/O Deposit</div>
                      </td>
                         <td data-label="Cross_selling_rate_val">
                        	<div class="slds-truncate" title="Cross_selling_rate_val">
                             	<lightning:formattedNumber value="{!v.campaign.cel_SalesTargetResWODeposit__c}" style="currency"/>  
                            </div>
                      	</td>
                       <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                        
                       <td data-label="Total_SLG">
                        <div class="slds-truncate" title="Total SLG">Total SLG</div>
                      </td>
                      <td>
                        <div class="slds-truncate">                           
                           <lightning:formattedNumber value="{!v.campaign.cel_TotalSLG__c}" style="currency"/></div>
                      </td>
                    </tr>                              
                 <!-- *************** -->
                    <tr>
                      <td data-label="Show_up">
                        <div class="slds-truncate" title="Show_up">Total show-up</div>
                      </td>
                      <td data-label="Val_Show_up">
                        <div class="slds-truncate" title="Val_Show_up">
                        	 <lightning:formattedNumber value="{!v.campaign.cel_TotalShowUp__c}"/>
                       </div>
                      </td>
                      <td>
                        <div class="slds-truncate" >Total purchasing</div>
                      </td>                   
                      <td data-label="Resa_whithout_deposit_amount">
                        <div class="slds-truncate" >
                          	 <lightning:formattedNumber value="{!v.campaign.cel_TotalPurchasing__c}" style="currency"/>
                        </div>
                      </td>
                      <td >
                        <div class="slds-truncate" ></div>
                      </td>
                      <td data-label="Target_achieved">
                        <div class="slds-truncate" title="Target_achieved">Store(s)</div>
                      </td>                        
                      <td data-label="Target_achieved_val">
                       	<div class="slds-truncate" >                           
                        	<lightning:formattedText value="{!v.campaign.cel_Stores__c}" style="string"/>
                        </div>
                      </td> 
                        
                      <td data-label="Target_achieved_val_euro">
                        <div class="slds-truncate" title="Target_achieved_val_euro"></div>
                      </td>
                        
                      <td data-label="Show_up">
                        <div class="slds-truncate" title="Show_up">Total RTW</div>
                      </td>
                      <td data-label="TotalRTw">
                        <div class="slds-truncate" title="TotalRTW">
                        	 <lightning:formattedNumber value="{!v.campaign.cel_TotalRTW__c}"/>
                       </div>
                      </td>  
                        
                      <td data-label="Target_achieved_val_euro">
                        <div class="slds-truncate" title="Target_achieved_val_euro"></div>
                      </td>
                    </tr>
          
                 <!-- Store -->
                 <tr >                    
                      <td data-label="Show_up">
                        <div class="slds-truncate" title="Show_up"> total Shoes</div>
                      </td>
                      <td data-label="TotalShoes">
                       <div class="slds-truncate" title="TotalShoes">
                        	 <lightning:formattedNumber value="{!v.campaign.cel_TotalShoes__c}"/>
                       </div>
                      </td>                                      
                      <td data-label="Show_up">
                        <div class="slds-truncate" title="Show_up"> total Bags</div>
                      </td>
                      <td data-label="TotalBags">
                       <div class="slds-truncate" title="TotalBags">
                        	 <lightning:formattedNumber value="{!v.campaign.cel_TotalBags__c}"/>
                       </div>
                      </td> 
                      <td data-label="Val_Purchasing_percent">
                        <div class="slds-truncate" title="Val_Purchasing_percent"></div>
                      </td>
                      <td data-label="TotalACC">
                        <div class="slds-truncate" title="TotalACC">Total ACC</div>
                      </td> 
                      <td data-label="Total ACC">
                        <div class="slds-truncate" title="otal ACC">
                           <lightning:formattedNumber value="{!v.campaign.cel_TotalACC__c}" style="currency"/>
                        </div>
                      </td>
                        <td data-label="emp">
                        <div class="slds-truncate" title="emp"></div>
                      </td>
                      <td data-label="Men/Women">
                        <div class="slds-truncate" title="Men/Women">Men/Women</div>
                      </td>                        
                      <td data-label="Men/Women">
                       	<div class="slds-truncate" >                           
                        	<lightning:formattedText value="{!v.campaign.cel_MenWomen__c}" style="string"/>
                        </div>
                      </td>    
                 </tr>
        </table>
    </div>
</aura:component>
 
// Controller JS 


({
    doInit: function(component, event, helper) {
      var action = component.get("c.getCampaign");
          action.setParams({ CampaignId : component.get("v.recordId") }); 
          action.setCallback(this, function(response){
      var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.campaigns", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action);
    },
    
     clickActive: function(component, event, helper) {
        var campaign = component.get("v.recordId");
        campaign.setParams({ "campaign": campaign });
        campaign.fire();
    }
})
 
// Controller Js helper

({ 
   doInit: function(component, event, helper) {
      var action = component.get("c.recordId");         
          action.setParams({recordId : component.get("v.recordId")});            
          action.setCallback(this, function(response) {
      var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.recordId", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        $A.enqueueAction(action);
    },  
    clickActive: function(component, event, helper) {
        var campaign = component.get("v.recordId");
        campaign.setParams({ "campaign": campaign });
        campaign.fire();
    }
})

 
Juan GarcíaJuan García 
Hi,

I have a datatable, and I need a text column with hiperlink to the reference object.
I want a similar table to a standard list view, the name of the column record is a hiperlink of the record page

Example:
List view of a record:
User-added image

Datatable with a colum type url
User-added image

Datatable with a colum type text
User-added image

Code:
cmp.set('v.columns', [
            {label: 'Recurso', fieldName: 'Name', type: 'url', sortable: true, editable:'true', initialWidth: 120},
        ]);

Thanks
Best Answer chosen by Juan García
Alain CabonAlain Cabon
Hi,

You need two fields: a shown label and a value for the underlying url.

Component:

  cmp.set('v.columns', [ 
       {
                label: 'My Column Label',
                fieldName: 'myUrlField',
                type: 'url',
                typeAttributes: { label: {fieldName: 'myLabel'}},
                sortable:false
            },
... ]);

Controller:
                    myUrlField =   '/one/one.app?#/sObject/' + item.Id + '/view';
                    myLabel = 'My test of label':