• Raj Vakati
  • ALL STAR
  • 28766 Points
  • Member since 2016

  • Chatter
    Feed
  • 938
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 8152
    Replies
I covered 40% with the below test class. Help me to cover 75%.
Apex Class:
public class FFQExt 
{
Public attachment objAttachment
{
get
{
if (objAttachment == null)
objAttachment = new Attachment();
return objAttachment ;
}
set;
}
public Id recordId {get; set;}
Public FFQ__C l{get; set;}
public String currentRecordId {get;set;}
public FFQExt(ApexPages.StandardController stdCon) 
{
currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
this.recordId = stdCon.getId();
this.l = (FFQ__c)stdCon.getRecord();  
objAttachment = new Attachment();
l = new FFQ__c();
l = [select Name, id, Business_Address__c, Business_Phone_Number__c, City__c, Client__c, Corporate_Structure__c, County__c, CPA_Contact__c, CPA_Contact_Email__c, 
CPA_Contact_Name__c, CPA_Contact_Phone__c, Do_you_ever_rehire_employees__c, MultipleEIN__c, Do_you_have_plans_for_Future_Expansion__c, Do_you_have_Recent_Expansion__c,
EIN__c, Estimated_Date_of_Tax_Filing__c, estimated_number_of_employees_hired_per__c, Executive_Contact__c, Executive_Contact_Email__c, Executive_Contact_Name__c,
Executive_Contact_Phone__c, Federal_Empowerment_Zone_Wage_Credit__c, First_Name__c, First_NameofPerson__c, Fiscal_Year_End_Date__c, General_Tax_Status__c, 
How_many_current_employees_do_you_have__c, How_many_W2s_were_distributed_last_year__c, HR_Contact__c, HR_Contact_Email__c, HR_Contact_Name__c, HR_Contact_Phone__c,
HR_Platform_to_onboard_your_Employees__c, Indian_Employment_Tax_Credit__c, Invoice_Contact__c, Invoice_Contact_Email__c, Invoice_Contact_Name__c, Invoice_Contact_Phone__c,
Legal__c, Is_your_business_Seasonal__c, I_understand__c, Last_Name__c, Last_NameofPerson__c, Legal_Address__c, Legal_City__c, Legal_County__c, Legal_Entity_Name__c, Legal_State__c,
Legal_Zip__c, list_all_locations_worksites__c, Payroll_Contact__c, Payroll_Contact_Email__c, Payroll_Contact_Name__c, Payroll_Contact_Phone__c, Please_list_all_EIN_Legal_Entities_below__c, 
Primary_Contact_Email__c, Primary_Contact_Number__c, Primary_Contact_Title__c, State__c, States_State_IDs_with_Tax_Liability__c, State_Specific_Incentives__c, To_begin_participation__c,
Which_HR_Platform_are_you_utilizing__c, Which_Payroll_Provider_are_you_using__c, WOTC__c, Zip__c from FFQ__c where id =: currentRecordId ];

}
Public void dosave()
{
if(objAttachment.body == null) 
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please upload your Documents'));
return ApexPages.CurrentPage();
}
else
{
upsert l;
objAttachment.ParentId = l.id;
try 
{
upsert objAttachment;
}
catch (DMLException e) 
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error Submitting Form'));
return null;
}
finally
{
objAttachment.body = null; // clears the viewstate
objAttachment = new Attachment();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Form Submitted Successfully'));
 PageReference mypage = new PageReference('/apex/thankyou');
   mypage.setRedirect(true);
   return mypage;
return null;
}
}
}
Test Class:
 
@isTest
private class FFQExt_Test1{
  @testSetup
  static void setupTestData(){
    test.startTest();
    FFQ__c ffq_Obj = new FFQ__c(Name = 'Name714', First_Name__c = 'First917', Last_Name__c = 'Last_775', Primary_Contact_Title__c = 'Prima305', Primary_Contact_Email__c = 'Email16@test.com', Primary_Contact_Number__c = '54343-6724', Business_Address__c = '18', City__c = 'City__c632', State__c = 'Alabama', Zip__c = 'Zip__c497', Business_Phone_Number__c = '54343-92658', Legal_Entity_Name__c = 'Legal220', Legal__c = false, EIN__c = 25, MultipleEIN__c = false, Please_list_all_EIN_Legal_Entities_below__c = '27', list_all_locations_worksites__c = '28', Corporate_Structure__c = 'C-Corp', Estimated_Date_of_Tax_Filing__c = Date.today(), General_Tax_Status__c = 'Paying Regular Tax', Fiscal_Year_End_Date__c = Date.today(), States_State_IDs_with_Tax_Liability__c = '33', Do_you_have_Recent_Expansion__c = false, Do_you_have_plans_for_Future_Expansion__c = false, Executive_Contact_Name__c = 'Execu607', Executive_Contact_Email__c = 'Email37@test.com', Executive_Contact_Phone__c = '54343-11689', CPA_Contact_Name__c = 'CPA_C106', CPA_Contact_Phone__c = '54343-93693', CPA_Contact_Email__c = 'Email41@test.com', HR_Contact_Name__c = 'HR_Co140', HR_Contact_Email__c = 'Email43@test.com', HR_Contact_Phone__c = '54343-70632', Invoice_Contact_Name__c = 'Invoi739', Invoice_Contact_Email__c = 'Email46@test.com', Invoice_Contact_Phone__c = '54343-50578', Payroll_Contact_Name__c = 'Payro557', Payroll_Contact_Email__c = 'Email49@test.com', Payroll_Contact_Phone__c = '54343-67706', HR_Platform_to_onboard_your_Employees__c = 'Yes', Which_HR_Platform_are_you_utilizing__c = 'Which567', Which_Payroll_Provider_are_you_using__c = 'Which997', How_many_current_employees_do_you_have__c = 54, How_many_W2s_were_distributed_last_year__c = 55, estimated_number_of_employees_hired_per__c = 'estim415', Is_your_business_Seasonal__c = 'Is_yo660', Do_you_ever_rehire_employees__c = 'Do_yo497', First_NameofPerson__c = 'First430', Last_NameofPerson__c = 'Last_585', Legal_Address__c = '61', Legal_City__c = 'Legal521', Legal_Zip__c = 63, Legal_State__c = 'Alabama', WOTC__c = false, State_Specific_Incentives__c = false, Federal_Empowerment_Zone_Wage_Credit__c = false, Indian_Employment_Tax_Credit__c = false, Executive_Contact__c = false, CPA_Contact__c = false, HR_Contact__c = false, Invoice_Contact__c = false, Payroll_Contact__c = false, To_begin_participation__c = '74', County__c = 'Count208', Legal_County__c = 'Legal590', I_understand__c = 'Yes');
    Insert ffq_Obj; 
    test.stopTest();
  }
  static testMethod void test_dosave_UseCase1(){
    List<FFQ__c> ffq_Obj  =  [SELECT Id,Name,First_Name__c,Last_Name__c,Primary_Contact_Title__c,Primary_Contact_Email__c,Primary_Contact_Number__c,Business_Address__c,City__c,State__c,Zip__c,Business_Phone_Number__c,Legal_Entity_Name__c,Legal__c,EIN__c,MultipleEIN__c,Please_list_all_EIN_Legal_Entities_below__c,list_all_locations_worksites__c,Corporate_Structure__c,Estimated_Date_of_Tax_Filing__c,General_Tax_Status__c,Fiscal_Year_End_Date__c,States_State_IDs_with_Tax_Liability__c,Do_you_have_Recent_Expansion__c,Do_you_have_plans_for_Future_Expansion__c,Executive_Contact_Name__c,Executive_Contact_Email__c,Executive_Contact_Phone__c,CPA_Contact_Name__c,CPA_Contact_Phone__c,CPA_Contact_Email__c,HR_Contact_Name__c,HR_Contact_Email__c,HR_Contact_Phone__c,Invoice_Contact_Name__c,Invoice_Contact_Email__c,Invoice_Contact_Phone__c,Payroll_Contact_Name__c,Payroll_Contact_Email__c,Payroll_Contact_Phone__c,HR_Platform_to_onboard_your_Employees__c,Which_HR_Platform_are_you_utilizing__c,Which_Payroll_Provider_are_you_using__c,How_many_current_employees_do_you_have__c,How_many_W2s_were_distributed_last_year__c,estimated_number_of_employees_hired_per__c,Is_your_business_Seasonal__c,Do_you_ever_rehire_employees__c,First_NameofPerson__c,Last_NameofPerson__c,Legal_Address__c,Legal_City__c,Legal_Zip__c,Legal_State__c,WOTC__c,State_Specific_Incentives__c,Federal_Empowerment_Zone_Wage_Credit__c,Indian_Employment_Tax_Credit__c,Executive_Contact__c,CPA_Contact__c,HR_Contact__c,Invoice_Contact__c,Payroll_Contact__c,To_begin_participation__c,County__c,Legal_County__c,I_understand__c from FFQ__c];
    System.assertEquals(true,ffq_Obj.size()>0);
    PageReference pageRef = Page.FFQ;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);
    FFQExt obj01 = new FFQExt(new ApexPages.StandardController(ffq_Obj[0]));
    obj01.objAttachment = new attachment();
    obj01.recordId = '01p90000006uk2w';
    obj01.l = ffq_Obj[0];
    obj01.currentRecordId = 'test data';
    obj01.dosave();
  }
}


 

I am getting this error on line 0 in my apex code. This is for spring '19 PD1 maintenance

@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
    @HttpGet
    global static Contact doGet(){
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null){
            throw new FunctionalException('Id parameter is required');
        }
        List<Contact> results;
        try{
            results = [SELECT id, Name, Secret_Key__c FROM Contact WHERE id=:recordId WITH SECURITY_ENFORCED];
        }catch(QueryException e){}
        
        if (!results.isEmpty()) {
            result = results[0];
        }
        return result;
    }
    public class FunctionalException extends Exception{}
    public class SecurityException extends Exception{}
}

Hi, I am getting an error while completing a challenge.
"
The Opportunity Amount field does not appear to be tracking field value changes."

I am struggling to find this change. Please help. Thanks
 
Hi guys,

I'm relatively new to Apex and am struggling a bit with a Test Class - I hope you can help!

Here is my Apex Trigger to create new Community users when Contacts are inserted:
 
trigger NewCommUser on Contact (After insert) {
     
     if(Trigger.isInsert){ 
     
         for(Contact co : trigger.new){
            Contact con = [select id,email,firstName,lastname,accountId,Do_Not_Grant_Community_Access__c,Account_Status_Text__c from Contact where Id =:co.Id];         
            Database.DMLOptions dmo = new Database.DMLOptions();
            dmo.EmailHeader.triggerUserEmail = false;       
            dmo.EmailHeader.triggerOtherEmail = false;
            dmo.EmailHeader.triggerAutoResponseEmail = false;       
            dmo.optAllOrNone = false;

            // Create Community Hub user
            List<User> unames = [select username from user where email =:con.email LIMIT 1];
            List<Contact> accountstatus = [select id from contact where Account_Status_Text__c = 'Signed-Up' and Id=:co.Id LIMIT 1];
            
            string userAlias;
            if (con.firstName.length() > 8)
            userAlias = con.firstName.substring(0,8); else userAlias = con.firstName;    
            
            if(unames.isEmpty() && !con.Do_Not_Grant_Community_Access__c && accountstatus.Size()>0){
                string nick = con.email!=null?con.email.substring(0, con.email.indexOf('@')):''; 
                nick += Datetime.now().getTime();
                User newUser1 = new User(alias=userAlias, email = con.email, emailencodingkey = 'UTF-8', firstname = con.firstName, lastname = con.lastname, languagelocalekey = 'en_US',localesidkey = 'en_GB',contactId = con.Id,timezonesidkey = 'Europe/London',username = con.email,CommunityNickname = nick,ProfileId ='00e58000000NkUd', IsActive = true);
                newUser1.setOptions(dmo); insert newUser1;
            }
         }
     }
}

And here is my Test Class:
 
@isTest
public class NewCommUserTest {
    
    @Testsetup
    static void dataSetup() {
        
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
    String orgId = UserInfo.getOrganizationId();
    String dateString = String.valueof(Datetime.now()).replace(' ','').replace(':','').replace('-','');
    Integer randomInt = Integer.valueOf(math.rint(math.random()*1000000));
    String uniqueName = orgId + dateString + randomInt;
        
        
        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=uniqueName + '@test' + orgId + '.org');
        
        u.UserRoleId=[select Id from UserRole where Name='CEO'].Id;
        
        //System.debug([select Id from UserRole where Name='CEO']);
        insert u;
       
        System.runAs(u) {
            Account a = new Account();
            a.Name = 'Test Account';
            insert a;                 
            
            Contact c = new Contact();
            c.LastName = ' Contact1';
            c.FirstName = 'test';
            
            c.Account_Status_Text__c = 'Signed-Up';
            c.Email = 'standarduser1@testorg.com';
            c.Do_Not_Grant_Community_Access__c = true;
            c.AccountId = a.Id;
            insert c;
            
            c.Do_Not_Grant_Community_Access__c = FALSE;
            update c;
        }
        
        
    }    
    
    @isTest static void testUpdateOrgForNewBusiness2() { 
        
        Account a = [select Id from Account limit 1];
        Contact c = new Contact();
        c.LastName = 'Contact1234';
        c.FirstName = 'test';
        
        c.Account_Status_Text__c = 'Signed-Up';
        c.Email = 'standarduser1@testorg.com';
        c.Do_Not_Grant_Community_Access__c = true;
        c.Account = a;
        insert c;
        
        c.Do_Not_Grant_Community_Access__c = FALSE;
        c.LastName = 'Contact1';
        update c;
        
    }
    
}

I'm currently at 73% coverage but so far am having trouble with this part of my Trigger:
 
string nick = con.email!=null?con.email.substring(0, con.email.indexOf('@')):''; 
nick += Datetime.now().getTime();
User newUser1 = new User(alias=userAlias, email = con.email, emailencodingkey = 'UTF-8', firstname = con.firstName, lastname = con.lastname, languagelocalekey = 'en_US',localesidkey = 'en_GB',contactId = con.Id,timezonesidkey = 'Europe/London',username = con.email,CommunityNickname = nick,ProfileId ='00e58000000NkUd', IsActive = true);
newUser1.setOptions(dmo); insert newUser1;

Can anyone please help me with how I can add this in my Test Class?

Thanks,

Tristan

 
Hey everyone! I'm still very new to Apex Code, but I've been trying to implement Chili Piper, and a portion of it allows you to automatically convert leads to contacts and opportunities: https://support.chilipiper.com/article/70-convert-lead-to-account-and-auto-create-an-opportunity-upon-booking-meeting

I've created a Sandbox environment, and built this Apex Class:
 
global class AutoConvertLeads implements Schedulable{

global Set<Id> LeadIds;

global void execute(SchedulableContext sc) {

LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
for(Id leadId : LeadIds){
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(leadId);
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
System.debug('LeadAssign Success');
}
System.abortJob(sc.getTriggerId());
}

public AutoConvertLeads (Set<Id> LeadIds) {
this.LeadIds=LeadIds;
}

}

Then I created this event trigger:
 
trigger ChangeTheOwnerAndConvert on Event (after insert) {
   Set<Id> LeadIds = new Set<Id>();
   for (Event e: Trigger.new){
   if (e.WhoId != null){
        String eventNameId = e.WhoId;
        if (!String.isBlank(e.Meeting_Type_CP__c)){
            if (e.Meeting_Type_CP__c.equals('Demo Request - Standard')){
                 LeadIds.add(e.WhoId);
                 Lead l = new Lead( Id = e.WhoId);
                 l.OwnerId = e.OwnerId;
                 update l;
                }
          }     
     }
   }
   if(LeadIds.size() > 0){
       Datetime sysTime = System.now();
       sysTime = sysTime.addSeconds(10);
       String chron_exp = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
       System.schedule('ConvertLead' + UserInfo.getUserId() + sysTime,chron_exp,new AutoConvertLeads(LeadIds));
   }
}

The Event Trigger is checked as "Is Active", but when I create a lead and create an event on that least with the Meeting Type = Demo Request - Standard, nothing happens.

Does anyone have insight into this? Would love any help!
Hi all,

I have two object: Events and Opportunities. What I would like to have happen is the following:

When the field Engineer__c is filled out on an Opportunity, I would like for the related Events field Client_Services__c field to be filled out with the same content. 

I know this will most likey be done with an Apex Trigger but I need some help with the code. In the past I have successfully done something similar but they were both the same object type. It seems the two different object types make it more complicated. 

Any insight would be appreciated.

Thanks,
Liz
Hey all, I have an after trigger that runs fine and everything updates correctly. But I'm not sure why on my test class it's not running when I systemAssert at the end. 

public class OpportunityHelper {
    public static void updateDistributions(map<Id, Opportunity> newMap, map<Id, Opportunity> oldMap){
        for(Id opportunityID : newMap.keyset()){
            //get donations with their related distributions
            List<Opportunity> distributionsID = [
                SELECT (SELECT Id FROM DistributionDonation__r) 
                FROM Opportunity 
                WHERE Id = :opportunityID
            ];
            
            //check if donation date changed
            if(oldMap.get(opportunityID).CloseDate != newMap.get(opportunityID).CloseDate){
                Date newDate = newMap.get(opportunityID).CloseDate;
                //updated all related distributions
                for(Opportunity Opp : distributionsID) {
                    for(Product_Distribution__c distribution : Opp.DistributionDonation__r){
                        distribution.Date_TBD__c = newDate;
                    }
                    update Opp.DistributionDonation__r;
                }
            }
}
}

@isTest
public class OpportunityHelperTest {
    static testMethod void testDateChange() {

        Test.startTest();

        Product_Distribution__c insertedTest = TestHelper.createRecords();

        Date newDate = Date.newInstance(2001, 01, 01);
        
        Opportunity opp = [SELECT ID, CloseDate From Opportunity Where ID =: insertedTest.Product_Donation_Name__c];

        opp.CloseDate = newDate;

        Test.stopTest();

        Product_Distribution__c dis = [Select ID, Product_Donation_Name__c, Date_TBD__c From Product_Distribution__c Where ID =: insertedTest.Id];
        
        System.assertEquals(opp.CloseDate, dis.Date_TBD__c);
        
    }
}

It always ends up not updating and instead just gets the date that was initalized with. 


System.AssertException: Assertion Failed: Expected: 2001-01-01 00:00:00, Actual: 2019-05-13 00:00:00
  • May 13, 2019
  • Like
  • 0
I've got an apex:chart that's rendering some data from a custom controller. 

I'm using an apex:barseries to display the data, and I've chosen to select stacked="true", which stacks two integer values onto the same column. 

The problem is, when you define the fields for that axis (in this case the right y axis), you give the axis a Title (i.e., Number of Customers), but when you display the Legend, there is no way to dicipher what each grouping in the stacked column represents. The Legend will just display the Title of the axis for each unique grouping. 

Does anyone know how to indicate a unique value for each group within the Legend? Thanks ~

User-added image

Hey everyone! I've been trying to implement this code snippet, but keep running into errors around Apex Identifiers:

 

Error: Compile Error: Invalid identifier '’00Q’'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 6 column 36
 

Error: Compile Error: Invalid identifier '‘Demo'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 7 column 45
 

Error: Compile Error: Invalid identifier '”'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 17 column 27


Here is the code:

trigger ChangeTheOwnerAndConvert on Event (after insert) {
   Set<Id> LeadIds = new Set<Id>();
   for (Event e: Trigger.new){
   if (e.WhoId != null){
        String eventNameId = e.WhoId;
        if (eventNameId.startsWith(’00Q’) && !String.isBlank(e.Meeting_Type_CP__c)){
            if (e.Meeting_Type_CP__c.equals(‘Demo Request - Standard’)){
                 LeadIds.add(e.WhoId);
                 Lead l = new Lead( Id = e.WhoId);
                 l.OwnerId = e.OwnerId;
                 update l;
                }
          }     
     }
   }
   if(LeadIds.size() > 0){
       Datetime sysTime = System.now();
       sysTime = sysTime.addSeconds(10);
       String chron_exp = ” + sysTime.second() + ‘ ‘ + sysTime.minute() + ‘ ‘ + sysTime.hour() + ‘ ‘ + sysTime.day() + ‘ ‘ + sysTime.month() + ‘ ? ‘ + sysTime.year();
       System.schedule(‘ConvertLead’ + UserInfo.getUserId() +sysTime,chron_exp,new AutoConvertLeads(LeadIds));
   }
}

Does anyone know how to get around this? I'm very new to all of this still and took the code from this article: https://support.chilipiper.com/article/70-convert-lead-to-account-and-auto-create-an-opportunity-upon-booking-meeting


Thank you so much to anyone that can even attempt to help!
Helper Class:
public class test{
public static void addContactRole(List<Opportunity> opps) {
List<OpportunityContactRole> oppCR=new List<OpportunityContactRole>();
        for(Opportunity opp : opps ){
           
            if(opp.StageName != 'Prospecting' && opp.StageName != 'Qualification' ){
           
            
              oppCR= [Select Id, opportunityId FROM OpportunityContactRole WHERE opportunityId =:opp.Id];
               
                if(oppCR == null || oppCR.size() == 0){
                   
                    opp.addError(' Opportunity must have at least one Contact Role assigned for any stages beyond 1');
                }
            }
        }
    }

Trigger:
trigger updatecontactrolecount on Opportunity (before insert, before update)
{
test.addContactRole(Trigger.New);
 
}

Note: If opportunity stage is other than Prospecting and Qualifiation then opportunity must have at least one contact role.(working fine but getting to many soql query error for bulk update or insert)
 
I have a lightning component with aura iteration. i want to dspaly only up to 5 records in the boxes.
variable 'FslFromBox' is having around 70 records here. and i am displaying this in one single div box. In this box, i want only 5 records to be shown. rest of the records(after 5 iterations) should not be shown on the box.
how to achieve this?

Code is below.
<aura:attribute name="FslFromBox" type="list"/>
<div style="background-color:#1589ee" class="slds-col slds-size_3-of-12 fslContainer">
                <div class="userName">
                    <aura:iteration items="{!v.FslFromBox}" var="FslFromBox" indexVar="int">

                            <aura:if isTrue="{!and((FslFromBox.ASQ_12MM__c ge 30),(FslFromBox.ASQ_Close_Rate__c ge 0),(FslFromBox.ASQ_Close_Rate__c lt 10))}">
                             <div class="demo-only">
                                    <span>
                                        <lightning:formattedText value="{!FslFromBox.User__r.Name}"/></span>    
                                </div>
                            </aura:if>
                    </aura:iteration>
                </div>
</div>

 
var action2 = component.get("c.getAccount");
        action2.setParams({
            "currentRecordId" : component.get("v.recordId")
        });
        action2.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.account", response.getReturnValue());
                console.log(response.getReturnValue());
            }
        });
        $A.enqueueAction(action2);
 
<aura:attribute name="account" type="Account" 
                    default="{ 'sobjectType': 'Account' }"/>
    <aura:attribute name="recordId" type="Id" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <div id="Modal_Parent" style="height:640px; width:1500px;">
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <header class="slds-modal__header">
                    <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Modal Test</h2>
                </header>
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                    <p>Display the Name </p>
                    <force:outputField value="{!v.account.Name}"/>
                    {!v.account.Name}
                    <p></p>
                </div>

            </div>
 
@AuraEnabled
    public static List<Account> getAccount(String currentRecordId) {
        System.debug('AccountRecord' + currentRecordId);
        return [select Id, Name from Account where Id =: currentRecordId];
    }

 
I have a trigger on the Opportunity object that concatenates all Products (OpportunityLineItem) within an Opportunity. I'm trying to also look at the OpportunityLineItemSchedule which is a child of OpportunityLineItem within the same SOQL. 

I am unable to choose a specific child from OpportunityLineItemSchedule.
For example, I'd like to see all Products from Opportunity A where the scheduledate from the opportunitylineitemschedule is the earliest (first installment). 
 
trigger concatenateProd on Opportunity (before insert, before update) {

list<opportunity> sl = trigger.new;
list<opportunityLineItem> slnu = new list<opportunityLineItem>([select id ,opportunityId, opportunity.name, Product_Family__c, (select Revenue from opportunitylineitemschedules where OpportunityLineItemId =: ??this.opportunitylineitem?? ORDER BY ScheduleDate ASC LIMIT 1) from opportunitylineitem where opportunityId =: trigger.new[0].id]);
 
string productName='';
for(opportunityLineItem opp : slnu){
 productName += opp.id +'||'+ opp.opportunityid +'||'+ opp.opportunity.name +'||'+ ???opp.opportunitylineitemschedules.Revenue??? +'\n'; 
}
for(Opportunity opp : trigger.new){
 opp.Concatenate_Prod__c = productName;
}
}
I get an error saying:
"Error: Compile Error: A non foreign key field cannot be referenced in a path expression: OpportunityLineItemSchedules at line 8"
I have a lightning component that opens from the Utility bar called OutOfOffice, the customer would like the window to auto close after pressing the Save button. Does anyone know how this can be accomplished? See the image below for visual.
User-added image
Hi All,
I am new to Lightning/salesforce. Trying to navigate to another object page using pageReference but getting this error  "This page has an error. You might just need to refresh it. [Cannot read property 'setParams' of undefined]" . Unable to get ti right following the developerguide sample. Thanks in advance!
Here are my controller and component:
Controller.js:
navigateBankAccount: function(component, event, helper) {
       var navService =  component.find("navService");
       var pageReference = {            
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Bank_Account__c',
                actionName: 'list'
            },
            state: {
               filterName: 'Recent'
            }
        };
        var pageReference = component.get("v.pageReference");
        event.preventDefault();
        navService.navigate(pageReference);
    },
----------------
Component :
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller = "CreateCustomerRecord" >
    <lightning:button label="Bank Account" onclick="{!c.navigateBankAccount}"/>
    <aura:attribute name="cust" type="Customer__c" default="{'sobjectType': 'Customer__c',
                                                            'Name': '',
                                                            'Phone__c': '',
                                                            'Email__c': '', 
                                                            'Phone__c': '',
                                                            'StreetAddress__c':'',
                                                            'StreetAddress__c': '',
                                                            'City__c': '',
                                                            'State__c': '',
                                                            'Country__c':'',
                                                            'Pincode__c':'',
                                                            'AdditionalInfo__c':''}" access="global" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
    <aura:attribute name="pageReference" type="Object"/>
    <lightning:navigation aura:id="navService"/>
      <aura:attribute name="picklistValues" type="Object" />
    <aura:attribute name="picklistValues1" type="Object" />
    <c:PicklistComponent sObjectName="Customer__c" fieldName="State__c" picklistValues="{!v.picklistValues}"/>
    <c:PicklistComponent sObjectName="Customer__c" fieldName="Country__c" picklistValues="{!v.picklistValues1}"/>
    <aura:attribute name="birthday" type="Date" default=""/>
    <lightning:input name = "name" label="Name"   
                     value="{!v.cust.Name}"/>                                    
    <lightning:input name = "eMail" label="email" 
                     value="{!v.cust.Email__c}"/>
    <lightning:input name = "phone" label="Phone" 
                     value="{!v.cust.Phone__c}"/>
    <lightning:input name = "streetAddress" label="StreetAddress" 
                     value="{!v.cust.StreetAddress__c}"/>
    <lightning:input name = "city" label="City" 
                     value="{!v.cust.City__c}"/>
    <lightning:select value="{!v.cust.State__c}" label = "State">       
        <option value="">Choose one...</option>
        <aura:iteration items="{!v.picklistValues}" var="i">
            <option value="{!i.value}">{!i}</option>
        </aura:iteration>
    </lightning:select>
    <lightning:select value="{!v.cust.Country__c}" label = "Country">       
        <option value="">Choose one...</option>
        <aura:iteration items="{!v.picklistValues1}" var="item">
            <option value="{!item.value}">{!item}</option>
        </aura:iteration>
    </lightning:select>
    <lightning:input name = "pincode" label="Pincode" 
                     value="{!v.cust.Pincode__c}"/>
    <ui:inputDate aura:id="expdate" label="Birthday" class="field" value="{!v.cust.Birthda__c}" displayDatePicker="true" />   
    
    <lightning:input name = "additionalInfo" label="AdditionalInfo" 
                     value="{!v.cust.AdditionalInfo__c}"/>
    <ui:inputCheckbox name = "kycVerified" label="KYCverified" value="{!v.cust.KYCverified__c}"/>
    <lightning:button label="Save Customer" 
                      onclick="{!c.saveCustomer}"/>
</aura:component>
Hi,

I am facing following Error while run a test class. 

Error : 
Methods defined as TestMethod do not support Web service callouts


Test Class : 
 
@isTest
public class AccountProcessorTest {
    
    @isTest
    public static void testFunc() {
        account acc = new account();
        acc.name = 'MATW INC';
        insert acc;
        
        contact con = new contact();
        con.lastname = 'Mann1';
        con.AccountId = acc.Id;
        con.email = '123@gmail.com';
        insert con;
        contact con1 = new contact();
        con1.lastname = 'Mann2';
        con1.AccountId = acc.Id;
        con.email = '124@gmail.com';
        insert con1;
        
        
        List<Id> acc_list = new List<Id>();
        acc_list.add(acc.Id);
        Test.startTest();
            AccountProcessor.countContacts(acc_list);
        Test.stopTest();
        List<account> acc1 = new List<account>([select Number_of_Contacts__c from account where id = :acc.id]);
        system.assertEquals(2,acc1[0].Number_of_Contacts__c);
    }

}

Note : Facing this error while cover a test class for @future Method 
 
public class AccountProcessor {
    
    @future
    public static void countContacts(List<Id> accountId_lst) {
        
        Map<Id,Integer> account_cno = new Map<Id,Integer>(); 
        List<account> account_lst_all = new List<account>([select id, (select id from contacts) from account]);
        for(account a:account_lst_all) {
            account_cno.put(a.id,a.contacts.size()); //populate the map
            
        }
                    
        List<account> account_lst = new List<account>(); // list of account that we will upsert
            
        for(Id accountId : accountId_lst) {
            if(account_cno.containsKey(accountId)) {
                account acc = new account();
                acc.Id = accountId;
                acc.Number_of_Contacts__c = account_cno.get(accountId);
                account_lst.add(acc);
            }
            
        }
        upsert account_lst;
    }

}


Regards,
Soundar.
I'm looking to create a process that will trigger an apex class when the user password is X number days away from expiring (only trigger once not over and over)  is this possible? I know SF has an email flow but that's not what I'm looking for.

Is it possible to use the process builder for this?
public class EventImportTriggerHandler {
    public static Boolean blnSkipEventUpdateTrigger = false;
    private boolean isExecuting = false;
    private integer BatchSize = 0;
    
    public EventImportTriggerHandler(boolean isExecuting, integer size){
        isExecuting = isExecuting;
        BatchSize = size;    
    }
    
    public void OnAfterInsert(EventbriteSync__EventbriteEventImport__c[] newEvent, Map<ID, EventbriteSync__EventbriteEventImport__c> newEventMap){ 
        if(!system.isBatch()){
            UpdateEventBatchClass upe = new UpdateEventBatchClass(newEvent[0].EventbriteSync__EventbriteId__c);
            Database.executeBatch(upe, 1);
        }
     }
     
     public void OnAfterUpdate(EventbriteSync__EventbriteEventImport__c[] oldEvent, EventbriteSync__EventbriteEventImport__c[] updatedEvent, Map<ID, EventbriteSync__EventbriteEventImport__c> eventMap, Map<Id, EventbriteSync__EventbriteEventImport__c> oldEventMap){
        if(!system.isBatch()){
            UpdateEventBatchClass upe = new UpdateEventBatchClass(oldEvent[0].EventbriteSync__EventbriteId__c);
            Database.executeBatch(upe, 1);
        }
        blnSkipEventUpdateTrigger = false;
        
     }
}
Hello all,

Hopefully a quick fix, but I'm not having much luck. We're trying to get it set up for an email to be sent out when a Work Order reaches certain statuses. It works as intended in our Sandbox environment, but when I try to create a Test Class, I can't seem to get code coverage for the email itself and I'm not sure why. When I run the test, pretty much everything dealing with the email is red, but everything else is blue. I don't know if there's a setting that I'm missing when it comes to testing emails through triggers, or if something needs to be changed in the code, but any suggestions would be greatly appreciated.

Trigger:
if ((newRecord.Status != trigger.oldMap.get(newRecord.Id).Status)
        && (newRecord.Status == 'Pending Complete'))
    {
        List<Messaging.SingleEmailMessage> sendAll = new List<Messaging.SingleEmailMessage>();
        
        for (Contact acctContact : [SELECT Id FROM Contact WHERE AccountId =: newRecord.AccountId AND Email_Pending_Complete__c = true])
                  {
                   ------Red Code Coverage Starts-----
                    Messaging.SingleEmailMessage statusEmail = new Messaging.SingleEmailMessage();
                    statusEmail.setTargetObjectId(acctContact.Id);
                    statusEmail.setWhatId(newRecord.Id);
                    statusEmail.setReplyTo('(Reply Email)');
                    statusEmail.setSenderDisplayName('(Display Name)');
                    statusEmail.setTemplateId('(Template ID)');
                    sendAll.add(statusEmail);
                  ------Red Code Coverage Ends-----
                  }
        Integer recCount = [SELECT count() FROM Contact WHERE AccountId =: newRecord.AccountId AND Email_Pending_Complete__c = true];
        if(recCount > 0)
        {
            ------Red Code Coverage Starts-----
            Messaging.sendEmail(sendAll);
            ------Red Code Coverage Ends-----
        }
    }

Test Method:
@isTest static void PendingStatus()
    {
        WorkOrder wOrderNew = new WorkOrder();
        wOrderNew.Snap_Contact__c = '(Contact)';
        wOrderNew.Client_Contact__c = '(Other Contact)';
        wOrderNew.End_User_Account__c = '(End User)';
        wOrderNew.ContactId = '(Yet Another Contact)';
        wOrderNew.AccountId = '(Account)';
        wOrderNew.Status = 'Scheduling';
        insert wOrderNew;
        
        Test.startTest();
        wOrderNew.Status = 'Pending Complete';
        update wOrderNew;
        Test.stopTest();
    }
Guys-

I am testing an apex class (projectCalloutService). I took a different approach and made some class variables static because to avoid having to pass any parameters to queueable interface ( just to try it out). However, my test methods assertion failed in projectCalloutServiceTest class. I use VScode for my dev work and I tried to debug using Apex replay debugger and found out that my Static Variables of the projectCalloutService class becomes null and I dont understand why. Any help is appreciated and most likely I am making a dumb mistake somewhere.. thanks in advance!
 
public class ProjectCalloutService {
    static Opportunity opportunityObj;
    static Opportunity opp ;
    
    
    @InvocableMethod(label='Post Opportunity To PMS' description='Synchronize Outbound Project Data')  
    public static void PostOpportunityToPMS(List<Id> opportunityIds) {
        Opportunity opp = [SELECT Amount,CloseDate,Id,Name,StageName,Account.Name FROM Opportunity WHERE Id =: opportunityIds.get(0)] ; 
        Opportunity opportunityObj;
        ID newJobId = System.enqueueJob(new QueueablePMSCall());
        System.debug(newJobId);
    }
    
    @Future(callout=true) 
    private static void makeServiceCall( ){
        
        opportunityObj = opp;
        JSONGenerator gen = JSON.createGenerator(true); // DO NOT USE JSON as variable (Case Insensitive)
        gen.writeStartObject();
        gen.writeStringField('opportunityId', opp.Id);
        gen.writeStringField('opportunityName', opp.Name);
        gen.writeStringField('accountName', opp.account.Name);
        gen.writeDateField('closeDate', opp.closeDate);
        gen.writeNumberField('amount', opp.amount);            
        gen.writeEndObject();      
        String jsonReq= gen.getAsString();
        System.debug('jsonReq: ' + jsonReq);
        
        
        
        
        ServiceTokens__c token= ServiceTokens__c.getValues('ProjectServiceToken');
        System.debug('TOKEN is :'+token.Token__c);
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('callout:ProjectService/'+token.Token__c);
        System.debug('ENDPOINT is :'+'callout:ProjectService/'+token.Token__c);
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        request.setBody(jsonReq);
        HttpResponse response = http.send(request);
        System.debug('RESPONSE is :'+response);
        
        
        // Parse the JSON response
        if (response.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
                         response.getStatusCode() + ' ' + response.getStatus());
            opportunityObj.StageName='Resubmit Project';
            upsert opportunityObj;
            
        } else {
            
            System.debug(response.getBody());
            opportunityObj.StageName='Submitted Project';
            upsert opportunityObj;
            
        }
        
        
        
    }
    
    
    
    // Queue 
    class QueueablePMSCall implements Queueable,Database.AllowsCallouts
    {
        
        public void execute(QueueableContext context) {
            
            makeServiceCall();
        }
        
    }
    
    
}
@isTest
private class ProjectCalloutServiceTest {
    
    @TestSetup
    static void makeData(){
        //create the Custom Settings
        ServiceTokens__c servToken = new ServiceTokens__c();
        servToken.Name = 'ProjectServiceToken';
        servToken.Token__c = 'jkhasbdha';
        insert servToken;
        
        Account testAcct = new Account(Name='TestOpAct');
        insert testAcct;
        
        List<Opportunity> oppList = new list<Opportunity>();
        Opportunity testOpp1 = new Opportunity(Name='TestOp1',StageName='Closed Won',Type='New Project',CloseDate=system.today(), AccountId = testAcct.id, Amount=50000);     
        Opportunity testOpp2 = new Opportunity(Name='TestOp2',StageName='Closed Won',Type='New Project',CloseDate=system.today(), AccountId = testAcct.id, Amount=50000);
        System.debug(testOpp1);
        oppList.add(testOpp1);
        oppList.add(testOpp2);
        upsert opplist; 
        System.debug(opplist);
        
        
        
        
        
        System.debug(testOpp1);
        
    }
    
    
    
    @isTest 
    public static void successTest(){    
        
        List<Id> oppIds = new List<Id>(new Map<Id,Opportunity>([SELECT Name,Id FROM Opportunity WHERE Name = 'Testop1']).keySet());
        
        // If an HTTP callout is invoked in test context, the callout is not made. Instead, you receive the mock response that you specify in the respond method implementation in AnimalLocatorMock.
        // Set mock callout class 
        
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMock()); 
        ProjectCalloutService.PostOpportunityToPMS(oppIds);
        Test.stopTest();
        
        
        Opportunity opp = [SELECT Name, StageName FROM Opportunity where Name='TestOp1'];
        System.assert(opp.StageName=='Submitted Project');
        
        
    }
    
    @isTest 
    public static void failureTest(){
        
        List<Id> oppIds = new List<Id>(new Map<Id,Opportunity>([SELECT Name,Id FROM Opportunity WHERE Name = 'Testop2']).keySet());
        
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMockFailure()); 
        ProjectCalloutService.PostOpportunityToPMS(oppIds);
        Test.stopTest();
        Opportunity opp = [SELECT Name, StageName FROM Opportunity where Name='TestOp2'];
        System.assert(opp.StageName=='Resubmit Project');
        
        
        
    }
    
    
    
}

 
I am generating random number of length 9 digits .. sometimes, the leading zero is dropped and I am getting less than 9 digits sometimes... so, I need to check the number length in apex ..if it;s less than 9 numbers I want to generate another one. How to get the length ?
  • May 17, 2019
  • Like
  • 0
How do i fix this issue?

({
    doInit : function(component,event,helper){
        var action = component.get("c.UserCheck");
        action.setParams({
            "currentRecordId" : component.get("v.recordId"),
            "currentUserId" : $A.get("$SObjectType.CurrentUser.Id")
        });
        action.setCallback(this,function(response){
            if(response.getState() == "SUCCESS"){
                //alert("hello there!" + response.getReturnValue()); 
                console.log(response.getReturnValue());
                if(response.getReturnValue()==true){
                    document.getElementById("Modal").setAttribute("style","height:640px;display:block;");
                    console.log(response.getReturnValue());
                }
                else{
                     document.getElementById("Modal").setAttribute("style","height:640px;display:none;");
                }
            }
        })
        $A.enqueueAction(action);
        
          var action2 = component.get("c.getAccount");
         action2.setParams({
            "currentRecordId" : component.get("v.recordId")
        });
        action2.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
               // alert("hello there!" + response.getReturnValue());
                component.set("v.account", response.getReturnValue());
                console.log(response.getReturnValue());
                /*if(response.getReturnValue()==true){
                    document.getElementById("Modal").setAttribute("style","height:640px;display:block;");
                    console.log(response.getReturnValue());
                }
                else{
                     document.getElementById("Modal_Parent").setAttribute("style","height:640px;display:none;");
                }*/
            }
         });
         $A.enqueueAction(action2); 
    
    },

 
I want to connect two orgs using REST API and retrieve one org data and save it in a object in other org.
I need to save data in a certain object of other org.
Please Help
need help to write the lightning component for below  classic java script button

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


if("{!$Profile.Name}" == "System Administrator") 


if (confirm("Are you sure you want to Create an Account in Oracle?") == true) 


var acctObj = new sforce.SObject("Account"); 
acctObj.Id = '{!Account.Id}'; 

acctObj.Create_Account_in_Oracle__c = true; 

var result = sforce.connection.update([acctObj]); 

if (result[0].success=='false') 

alert(result[0].errors.message); 

else 

alert("Account Creation Process has been submitted to Oracle"); 
window.parent.location.href="/{!Account.Id}"; 



}
I am planning to use custom settings..need a help

How to fetch a list from customer settings to my lighting component combo box

List of Colour : 
Red
Green
Blue

controller---------
var navService = component.find("navService");
        var pageReference = {
            type: "standard__component",
            attributes: {
                componentName: "c__peDetail"
            },
            state: {
                "projectId": PID
            } 
        };
       console.log(pageReference);
       navService.navigate(pageReference);

defined the variable in cmp -- 
<lightning:navigation aura:id="navService" />
    <aura:attribute name="pageReference" type="Object"/>


 
Hi,
I am sending an email through apex class to users. Email is going from (noreply@salesforce.com; on behalf of; XXX <xxx@xxx.com>.)
From user is current logged in user's email address which is my office email id. Previously it was working fine but now its has stopped. I checked Salesforce Email log file in column L value is "reading confirmation", Column O showing "550-5.7.1 Unauthenticated email from xxx.com is not accepted due to\r\n550-5.7.1 domain's DMARC policy".

Can anyone help me on this ?
Hi All,
How can i send emil with multiple attachment files.I have developed a controller for mail sending ,working fine.But unable to attach multiple files with the mail....
I want to assign my case to article automatically is there any way to assign.

 please help
Thanks in advanced
How to get the list of unused apex classes, triggers and visualforce pages
Hi,
How to call Scheduler class from the trigger?

Regards,
SFDC16
Hello,

I need to request Signed signed object either from the Controller or view of ASP.net MVC. I tried to use 

Sfdc.canvas.client.repost({refresh : true});

But got an erro Sfdc. is not defined. Can you give me an example how to request a signed request on demand
Hello Developer Support,

QUESTION:
Can you tell me how to remedy this error?

CONTEXT:
It appears this Flow is generating an error, which I believe means multiple processes are trying to edit the same record at the same time. It appears this UNABLE_TO_LOCK_ROW is the issue and can be remedied by locking the records using the FOR UPDATE keyword. Not sure how to do that...

I don't have experience with Apex code; thus, I would like to stay away from it. Looks like 124 leads were not able to be updated because multiple edits were happening at the same time on the same records.

ARTICLE:
https://developer.salesforce.com/forums/?id=9060G000000I2r1QAC

ERROR MESSAGE:
Error element Update_Person_Score (FlowRecordUpdate).
The flow tried to update these records: null. This error occurred: UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record or 124 records: 00Q3Z00000lPnucUAC,00Q3Z00000lPnmKUAS,00Q3Z00000lPnpmUAC,00Q3Z00000lPnmJUAS,00Q3Z00000lPnplUAC,00Q3Z00000lPnmdUAC,00Q3Z00000lPnprUAC,00Q3Z00000lPnmOUAS,00Q3Z00000lPnpnUAC,00Q3Z00000lPnmjUAC,00Q3Z00000lPnq6UAC,00Q3Z00000lPnmiUAC,00Q3Z00000lPnq1UAC,00Q3Z00000lPnmxUAC,00Q3Z00000lPnqBUAS,00Q3Z00000lPnmnUAC,00Q3Z00000lPnq7UAC,00Q3Z00000lPnmEUAS,00Q3Z00000lPnm9UAC,00Q3Z00000lPnpkUAC,00Q3Z00000lPnoPUAS,00Q3Z00000lPnrAUAS,00Q3Z00000lPnoGUAS,00Q3Z00000lPnqqUAC,00Q3Z00000lPnvBUAS,00Q3Z00000lPnoZUAS,00Q3Z00000lPnrOUAS,00Q3Z00000lPnoUUAS,00Q3Z00000lPnrJUAS,00Q3Z00000lPnofUAC,00Q3Z00000lPnr

All the best,
Andrew Slutzky
.addError(fieldMap.get(Start_Date__c).getDescribe().getLabel() +''+Label.Valuelabel);   

I want to get the field label dynamically by using API name inside addError() function to show error value with field label but unable to achieve. Please help me out with this.

.addError(Schema.getObj.getField(fieldAPI).getLabel() + '' + Label.xyz);---------I got suggestion still not working.


                    
Hello guys!

I've been struggling with a validation rule. There is a field called "Birthday" where the user populates his/her birthday. When the user populates this field, then it has to allow only ages higher than 17 years old.

For example:
User's birthday: 02/02/2005
Today's date: 15/05/2019
So it means that the user's age is bellow 18, hence it is not accepted. 

How can I do it? I've made it doing the following code, but it didn't work as I wanted:
(TODAY() - DadosPF_DataNascimento__c < 18*365)

I did other things, but there were incorret datas that were allowed instead of being denied. Could you guys please help me? 
 
I have a requirement that ananymous user who doesn't requre login to access a page, fills the details, saves to an object (custom, and it has lookup field  to contact) . For this I have done the below steps
  • Added Domain
  • Created new Site
  • Assigned the created VF page in to the list 'Site Visualforce Pages'
  • Activated the site
  • Gave perrmissions (RWA) to the custom object
But when I click on the page I got the following error
Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
We should directly access to the page without authorize, how can we do this?
Thanks,