+ Start a Discussion
svidyansvidyan 

Hi,

 

I am following the book "Developement with the Force.com platform" by JasonOuelette.

When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?

 

thanks

Svidya

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

It looks you havent create custom Tabs while defining custom objects first you need to create custom Tab for new objects Creating Tab Setup -->App Set up---> Create---> Tabs Click on new Tab [drop down shows all untabed objects ] select your object, set Tab style , click Next select profiles Save Adding To App Setup -->App Set up---> Create---> Apps Click on edit, edit available tab section Save Done Thanks, Bala

sharathchandra thukkanisharathchandra thukkani 
Not able to see Login button for all users on user detail page even if i'm an administrator in developer account. My "System administartor" profile has "Mange Users" and "Modify All Data" permission.
Best Answer chosen by sharathchandra thukkani
Swati GSwati G
You first login to the user for which you want to see login link and grant admin access.

After login, go to Setup ->  My Personal Information -> Grant Login Access and Grant Your Company's Administrator
vibrationvibration 

I want dump question in Salesforce Administration Certification.

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora
jprichterjprichter 
Admin Advanced >  Advanced Formulas > Using Basic Logic in Checkbox Formulas

The formula I used is:
NOT(IsClosed) && (CloseDate <= (Today() - 1))
Also tried:
AND(NOT(IsClosed),(CloseDate <= (Today() - 1)))

The error code I get is:

"Hey McFly, unless you are planning to go back in time, please update your close date"

Trialhead is giving the error:
Challenge Not yet complete... here's what's wrong: 
The validation rule does not reference the 'IsClosed' and 'CloseDate' fields correctly. Take a look at the requirements again.

When I test it out myself, it's working as expected. Any ideas on what it could be?
Best Answer chosen by jprichter
Jeff DouglasJeff Douglas
Everyone, give it a try now. We just pushed a fix so that should do the trick.

Jeff Douglas
Trailhead Developer Advocate
Wanda TWanda T 
I am confused.  I am on the Beginner Admin
Trail Module 4 - UI Customization


Add a button with a link to a contact.

To pass this challenge, create a custom button which opens a link to 'http://google.com/#q={CONTACTNAME}' - where {CONTACTNAME} is the current contact's name. Then add this button to the default 'Contact Layout'.The custom button must be named 'Google Link'.

What is the current contact name? Google Link?

The custom button must be added to the 'Contact Layout' page layout.  I am not findiing the default Contact Layout Page
Best Answer chosen by Wanda T
Amit Chaudhary 8Amit Chaudhary 8
Hi Wanda T,

To clear this challange you need do below steps:-

Step1 :- Create a Button on contact object like below 

User-added image

Step 2 :- Link detail should be like below.

Name :- Google_Link
Button or Link URL :-  http://google.com/#q={!Contact.Name}
Display Type :- Detail Page Button

User-added image
Step 3:- Add the button on contact page layout. Please select "Contact Layout"
User-added image

Step 4:- Then click on Edit and add button on page.
User-added image

Step 5:- Save.

Please let us know if this will help you.

Thanks
Amit Chaudhary
Ashley ZhaoAshley Zhao 
hi,all.
i am new here .
i want to combine process bulider and flow to complete that when i delete a record  ,the process will be trigger..can everybody help me?
for example , the Account object,i want to delete an account's case, when i delete it,it will trigger an outbound msg...
thx....
Best Answer chosen by Ashley Zhao
Shashi PatowaryShashi Patowary
Hi Ashley,

Workflow does not execute when a record is deleted. Hence you cannot send an outbound message from workflow directly on case record deletion from account.
However, you can do a workaround -
1.Create a checkbox field in account e.g Delete_Flag__c
2.Create a trigger on Case object with 'before delete' event and update the related Delete_Flag__c in account rceord when a case is deleted
3.Create a workflow in Account object that has filter on Delete_Flag__c field and create your required outbound message


Please let me know if it works.

Regards,
Shashi
Sudeep SinghSudeep Singh 
Class :- 

public class AutoConvertLead {
@InvocableMethod
public static void assignLeads(List<Id> LeadIds) { 
    try{ 
        Map<String,Date> NameDOBMap = new Map<String,Date>();
        List<String> leadNames = new List<String>();
        List<Date> leadDOBs = new List<Date>();
        List<Database.LeadConvert> massLeadConvert = new List<Database.LeadConvert>();
        List<Account> accountsToUpdate = new List<Account>();
        List<Account> accountsToInsert = new List<Account>();
        List<Contract> contractsToInsert = new List<Contract>();
        Map<String,Account> nameDOBToAccountMap = new Map<String,Account>();
        Map<String,Account> newCreatedAccounts = new Map<String,Account>();
        Map<ID,Id> leadProductMap = new Map<Id,Id>();
        
        Id personAccountRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Person Account').getRecordTypeId();
        LeadStatus cLeadStatus = [SELECT Id,MasterLabel FROM LeadStatus WHERE isConverted = true LIMIT 1];  
        
       // List<Lead> leads = [SELECT Id,Name,LastName,FirstName,Email,Date_Of_Birth__c,Service__c,Ethnicity__c, Race__c,Gender__c FROM Lead WHERE Id IN :LeadIds];
       Map<Id,Lead> leadmap= new Map<Id,Lead>([SELECT Id,Name,LastName,FirstName,Email,Date_Of_Birth__c,Service__c,Ethnicity__c,MobilePhone, Race__c,Gender__c,City,Country,State,Street,PostalCode FROM Lead WHERE Id IN :LeadIds]);
       // for(Lead lead: leads) {
        for(Lead lead: leadmap.values()) {
            leadNames.add(String.valueOf(lead.Name));
            leadDOBs.add(lead.Date_Of_Birth__c);
            NameDOBMap.put(lead.Name, lead.Date_Of_Birth__c);
            leadProductMap.put(lead.Id,lead.Service__c);
        }
        
        Map<Id, Account> existingAccounts = new Map<Id, Account>([SELECT Id, PersonBirthdate, Name, PersonGender FROM Account WHERE Name IN :NameDOBMap.KeySet() AND PersonBirthdate IN :NameDOBMap.values()]);
        
        for(account acc: existingAccounts.values()){
            
        }
        //System.debug('Check 1'+existingAccounts);
        for(Account accc: existingAccounts.values()){
            nameDOBToAccountMap.put(accc.Name+accc.PersonBirthdate, accc);
        }
        
       // for(Lead ld : leads){
        for(Lead ld: leadmap.values()) {
            if(!nameDOBToAccountMap.containsKey(ld.Name+ld.Date_Of_Birth__c)){
                Account existingAccount = new Account();
                existingAccount.LastName = ld.LastName;
                existingAccount.FirstName = ld.FirstName;
                existingAccount.PersonEmail = ld.Email;
                existingAccount.PersonGender = ld.Gender__c;
                existingAccount.RecordTypeId =  personAccountRecordTypeId;
                existingAccount.Ethnicity__pc = ld.Ethnicity__c;
                existingAccount.Race__pc = ld.Race__c;
                existingAccount.PersonGender = ld.Gender__c;
                existingAccount.PersonBirthdate = ld.Date_Of_Birth__c;
                existingAccount.PersonHomePhone = ld.MobilePhone;
                accountsToInsert.add(existingAccount);
            }  
        }
        
        if(accountsToInsert.size()>0){
            insert accountsToInsert;
        }
        //system.debug('accountsToInsert'+accountsToInsert);
        
        for(account acc: accountsToInsert){
            newCreatedAccounts.put(acc.FirstName+acc.LastName, acc);
        }
        //system.debug('newCreatedAccounts'+newCreatedAccounts);
        //for(Lead lead : leads){
            for(Lead lead : leadmap.values()){
            //System.debug('Check 2');
            Database.LeadConvert LeadConvert = new Database.LeadConvert();
            LeadConvert.setLeadId(lead.Id);
            LeadConvert.setConvertedStatus(cLeadStatus.MasterLabel);
            LeadConvert.setDoNotCreateOpportunity(false);
            
            if(lead.Name != null && lead.Date_Of_Birth__c != null){                    
                if(nameDOBToAccountMap.containsKey(lead.Name+lead.Date_Of_Birth__c) && nameDOBToAccountMap.get(lead.Name+lead.Date_Of_Birth__c)!=Null){
                    //system.debug('existingAccount==>'+nameDOBToAccountMap.get(lead.Name+lead.Date_Of_Birth__c));
                    Account existingAccount = new Account();
                    existingAccount.Id = nameDOBToAccountMap.get(lead.Name+lead.Date_Of_Birth__c).id;
                    //system.debug('existingAccount'+existingAccount);
                    existingAccount.Ethnicity__pc = lead.Ethnicity__c;
                    existingAccount.Race__pc = lead.Race__c;
                    existingAccount.PersonGender = lead.Gender__c;
                    existingAccount.PersonHomePhone = lead.MobilePhone;
                    accountsToUpdate.add(existingAccount);
                    LeadConvert.setAccountId(existingAccount.Id);
                }
                else{
                    //system.debug('lead.Name+lead.Date_Of_Birth__c'+lead.FirstName+lead.LastName);
                    if(newCreatedAccounts.containskey(lead.FirstName+lead.LastName) && newCreatedAccounts.get(lead.FirstName+lead.LastName)!= Null){
                        LeadConvert.setAccountId(newCreatedAccounts.get(lead.FirstName+lead.LastName).Id);
                    }  
                }
                //System.debug('LeadConvert.getAccountId()'+LeadConvert.getAccountId()); 
                massLeadConvert.add(LeadConvert);
                //system.debug('massLeadConvert'+massLeadConvert);
            }
        }
        
        if(!accountsToUpdate.isEmpty()){
            //system.debug('accountsToUpdate'+accountsToUpdate);
            update accountsToUpdate;
            //system.debug('accountsToUpdate'+accountsToUpdate);
            
        }
        
        if(!massLeadConvert.isEmpty()){
            //system.debug('massLeadConvert'+massLeadConvert);
            List<Database.LeadConvertResult> lcr = Database.convertLead(massLeadConvert);
            for(Database.LeadConvertResult leadConvertResult : lcr) {
                //system.debug('leadConvertResult'+leadConvertResult);
                //system.debug('accountid'+existingAccounts.containskey(leadConvertResult.accountid));
                if(leadConvertResult.isSuccess() && !existingAccounts.containskey(leadConvertResult.accountid) ) {
                    Contract contract = new Contract();
                    contract.Status = 'Draft';
                    contract.AccountId = leadConvertResult.getAccountId();
                    contract.StartDate = system.today();
                    contract.ContractTerm = 12;
                    if(leadProductMap.containskey(leadConvertResult.getLeadId()) && leadProductMap.get(leadConvertResult.getLeadId())!=Null){
                        contract.Service__c = leadProductMap.get(leadConvertResult.getLeadId());
                    }
                    if(leadmap.containskey(leadConvertResult.getLeadId())  ) {
                            
                        contract.BillingCity= leadmap.get(leadConvertResult.getLeadId()).City;
                        contract.BillingState= leadmap.get(leadConvertResult.getLeadId()).State;
                        contract.BillingCountry = leadmap.get(leadConvertResult.getLeadId()).Country;
                        contract.BillingStreet=leadmap.get(leadConvertResult.getLeadId()).Street;
                        contract.BillingPostalCode=leadmap.get(leadConvertResult.getLeadId()).PostalCode;
                        contract.ShippingCity = leadmap.get(leadConvertResult.getLeadId()).City;
                        contract.ShippingState = leadmap.get(leadConvertResult.getLeadId()).State;
                        contract.ShippingCountry = leadmap.get(leadConvertResult.getLeadId()).Country;
                        contract.ShippingStreet = leadmap.get(leadConvertResult.getLeadId()).Street;
                        contract.ShippingPostalCode = leadmap.get(leadConvertResult.getLeadId()).PostalCode;

                    }
                    contractsToInsert.add(contract);
                }
            }
        }
        
        if(!contractsToInsert.isEmpty()){
            insert contractsToInsert;
        }
    }catch(Exception e){
        //System.debug('Error: '+e.getMessage()+ 'Line Number'+e.getLineNumber());
    }
}
}


Test Class:- 

@isTest
public class Test_AutoConvertLead {
    @isTest
    static void testAutoConvertLead()
    {
        String recordTypeId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('Person Account').getRecordTypeId();
        Account acc= new Account(
        RecordTypeID=recordTypeId ,
        FirstName='Test FName',
        LastName='Test LName',
        PersonBirthdate = date.valueOf('1998-02-02') ,
        PersonGender = 'Male',
        PersonMailingStreet='test@yahoo.com',
        PersonMailingPostalCode='12345',
        PersonMailingCity='SFO',
        PersonEmail='test@yahoo.com',
        PersonHomePhone='1234567',
        PersonMobilePhone='12345678'   
        );        
        insert acc;
        
        Product2 p = new Product2();
        p.Name = 'Covid Test Kit';
        p.sstation__Msrp__c = 1;
        insert p;
        
        Lead ld = new lead();
        ld.LastName = 'test';
        ld.FirstName = 'class';
        ld.Email = 'test@gmail.com';
        ld.Date_Of_Birth__c = date.valueOf('1998-02-02') ;
        ld.Race__c = 'Asian';
        ld.Ethnicity__c = 'Hispanic or Latino';
        ld.Gender__c = 'Male';
        ld.Status = 'New';
        ld.Shipping_First_Name__c = 'test';
        ld.Shipping_Last_Name__c = 'class';
        ld.City = 'test';
        ld.Country = 'tes';
        ld.Street = 'test';
        ld.State = 'test';
        ld.PostalCode = '000000';
        ld.Service__c = p.Id;
        ld.MobilePhone = '9999999999';
        ld.Phone = '8888888888';
        insert ld;
        
        Account accc = new Account();
        accc.LastName = ld.LastName;
        accc.FirstName = ld.FirstName;
        accc.PersonEmail = ld.Email;
        //accc.PersonBirthdate = ld.Date_Of_Birth__c-3;
        accc.Race__pc = ld.Race__c;
        accc.Ethnicity__pc = ld.Ethnicity__c;
        accc.PersonGender = ld.Gender__c;
        accc.BillingCity = ld.City;
        accc.BillingCountry = ld.Country;
        accc.BillingPostalCode = ld.PostalCode;
        accc.BillingState = ld.State;
        accc.BillingStreet = ld.Street;
        accc.PersonHomePhone = ld.Phone;
        accc.PersonMobilePhone = ld.MobilePhone;
        insert accc;
        
  
        Contract cont = new Contract();
        cont.AccountId= accc.id;
        cont.StartDate=date.today();
        cont.ContractTerm=2;
        cont.Status='Draft';
        //cont.Pricebook2Id = standardPricebook.Id;
        //cont.Service__c = op.Id;
        //cont.Insurance__c = mp.Id;
        cont.BillingStreet = 'test';
        cont.BillingPostalCode = '759128';
        cont.BillingState = 'test';
        cont.BillingCity = 'test';
        cont.BillingCountry = 'test';
        cont.BillingLatitude = 20.296059;
        cont.BillingLongitude = 85.824539;
        cont.ShippingCity = 'test';
        cont.ShippingCountry = 'test';
        cont.ShippingPostalCode = '777777';
        cont.ShippingLatitude = 20.296059;
        cont.ShippingLongitude = 85.824539;
        cont.Service__c = p.Id;
        insert cont;
        
      
        {

            System.assert(True, 'ErrorMessage');
            
             }
        
        
        Test.startTest();
        Lead l = new Lead(LastName = 'Test Lead',
                     Company = 'Test Company',Race__c = 'Asian',Ethnicity__c = 'Hispanic or Latino'
                     );
        insert l;
        
        
        AutoConvertLead obj = new AutoConvertLead();
        //String CRON_EXP = '0 0 0 3 9 ? 2042';
        //system.schedule('Test status Check9', CRON_EXP, obj );
        AutoConvertLead.assignLeads(new List<String>{l.id});
        Test.stopTest();
        
  
        
        // For Schedulable AutoSubscriptionForOrderCreation
        
        
    }
          @isTest
    static void testAutoConvertLead2()
    {
        String recordTypeId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('Person Account').getRecordTypeId();
        Account acc= new Account(
        RecordTypeID=recordTypeId ,
        FirstName='Lead',
        LastName='Test',
        PersonBirthdate = date.valueOf('1998-02-02') ,
        PersonGender = 'Male',
        PersonMailingStreet='test@yahoo.com',
        PersonMailingPostalCode='12345',
        PersonMailingCity='SFO',
        PersonEmail='test@yahoo.com',
        PersonHomePhone='1234567',
        PersonMobilePhone='12345678',
        BillingStreet = 'Test',
        BillingCity = 'Test',
        BillingState = 'Test',
        BillingPostalCode = 'Test',
        BillingCountry = 'Test'
        );        
        insert acc;
        Lead l2 = new Lead(LastName = 'Test', FirstName = 'Lead',
                     Company = 'Test Company',Race__c = 'Asian',Ethnicity__c = 'Hispanic or Latino', Date_Of_Birth__c = date.valueOf('1998-02-02')
                     );
        insert l2;
        AutoConvertLead.assignLeads(new List<String>{l2.id});
    }
    
}

Code coverage is only 74%
Best Answer chosen by Sudeep Singh
Sudeep SinghSudeep Singh
@isTest
public class Test_AutoConvertLead {
    @isTest
    static void testAutoConvertLead()
    {
        String recordTypeId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('Person Account').getRecordTypeId();
        Account acc= new Account(
        RecordTypeID=recordTypeId ,
        FirstName='Test FName',
        LastName='Test LName',
        PersonBirthdate = date.valueOf('1998-02-02') ,
        PersonGender = 'Male',
        PersonMailingStreet='test@yahoo.com',
        PersonMailingPostalCode='12345',
        PersonMailingCity='SFO',
        PersonEmail='test@yahoo.com',
        PersonHomePhone='1234567',
        PersonMobilePhone='12345678'   
        );        
        insert acc;
        
        Product2 p = new Product2();
        p.Name = 'Covid Test Kit';
        p.sstation__Msrp__c = 1;
        insert p;
        
        Lead ld = new lead();
        ld.LastName = 'test';
        ld.FirstName = 'class';
        ld.Email = 'test@gmail.com';
        ld.Date_Of_Birth__c = date.valueOf('1998-02-02') ;
        ld.Race__c = 'Asian';
        ld.Ethnicity__c = 'Hispanic or Latino';
        ld.Gender__c = 'Male';
        ld.Status = 'New';
        ld.Shipping_First_Name__c = 'test';
        ld.Shipping_Last_Name__c = 'class';
        ld.City = 'test';
        ld.Country = 'tes';
        ld.Street = 'test';
        ld.State = 'test';
        ld.PostalCode = '000000';
        ld.Service__c = p.Id;
        ld.MobilePhone = '9999999999';
        ld.Phone = '8888888888';
        insert ld;
        
        Account accc = new Account();
        accc.LastName = ld.LastName;
        accc.FirstName = ld.FirstName;
        accc.PersonEmail = ld.Email;
        //accc.PersonBirthdate = ld.Date_Of_Birth__c-3;
        accc.Race__pc = ld.Race__c;
        accc.Ethnicity__pc = ld.Ethnicity__c;
        accc.PersonGender = ld.Gender__c;
        accc.BillingCity = ld.City;
        accc.BillingCountry = ld.Country;
        accc.BillingPostalCode = ld.PostalCode;
        accc.BillingState = ld.State;
        accc.BillingStreet = ld.Street;
        accc.PersonHomePhone = ld.Phone;
        accc.PersonMobilePhone = ld.MobilePhone;
        insert accc;
        
  
        Contract cont = new Contract();
        cont.AccountId= accc.id;
        cont.StartDate=date.today();
        cont.ContractTerm=2;
        cont.Status='Draft';
        cont.BillingStreet = 'test';
        cont.BillingPostalCode = '759128';
        cont.BillingState = 'test';
        cont.BillingCity = 'test';
        cont.BillingCountry = 'test';
        cont.BillingLatitude = 20.296059;
        cont.BillingLongitude = 85.824539;
        cont.ShippingCity = 'test';
        cont.ShippingCountry = 'test';
        cont.ShippingPostalCode = '777777';
        cont.ShippingLatitude = 20.296059;
        cont.ShippingLongitude = 85.824539;
        cont.Service__c = p.Id;
        insert cont;
 
        {
          System.assert(True, 'ErrorMessage');    
             }
        
 
        Test.startTest();
        Lead l = new Lead(LastName = 'Test Lead',
                     Company = 'Test Company',Race__c = 'Asian',Ethnicity__c = 'Hispanic or Latino', Date_Of_Birth__c = date.valueOf('1998-02-02')
                     );
        insert l;
        
        
        AutoConvertLead obj = new AutoConvertLead();
        //String CRON_EXP = '0 0 0 3 9 ? 2042';
        //system.schedule('Test status Check9', CRON_EXP, obj );
        AutoConvertLead.assignLeads(new List<String>{l.id});
        Test.stopTest();
    
        // For Schedulable AutoSubscriptionForOrderCreation
 
    }
          @isTest
    static void testAutoConvertLead2()
    {
        String recordTypeId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('Person Account').getRecordTypeId();
        Account acc= new Account(
        RecordTypeID=recordTypeId ,
        FirstName='Lead',
        LastName='Test',
        PersonBirthdate = date.valueOf('1998-02-02') ,
        PersonGender = 'Male',
        PersonMailingStreet='test@yahoo.com',
        PersonMailingPostalCode='12345',
        PersonMailingCity='SFO',
        PersonEmail='test@yahoo.com',
        PersonHomePhone='1234567',
        PersonMobilePhone='12345678',
        BillingStreet = 'Test',
        BillingCity = 'Test',
        BillingState = 'Test',
        BillingPostalCode = 'Test',
        BillingCountry = 'Test'
        );        
        insert acc;
        
        
        Lead l2 = new Lead(LastName = 'Test', FirstName = 'Lead',
                     Company = 'Test Company',Race__c = 'Asian',Ethnicity__c = 'Hispanic or Latino', Date_Of_Birth__c = date.valueOf('1998-02-02')
                     );
        insert l2;
        AutoConvertLead.assignLeads(new List<String>{l2.id});
    }
   
}
Sudeep SinghSudeep Singh 
How to set a value as default value in a lookup field?

 
Best Answer chosen by Sudeep Singh
SwethaSwetha (Salesforce Developers) 
HI Sudeep,
Looks like this is not possible. There is an Idea - https://ideas.salesforce.com/s/idea/a0B8W00000GdaiqUAB/default-value-for-a-lookup-field according to which,


"Work for this type of feature is shared across a few teams, and they're still investigating what it would take from each of them to deliver. As a workaround, however, it is possible to set default lookup values when creating a record via Quick Action. I know that doesn't cover every use case, but it may help alleviate some challenges in this area. I will keep updating this space as we learn more from the investigation. "

If this information helps, please mark the answer as best. Thank you
Brian KesslerBrian Kessler 
I'm currently still struggling with Einstein Analytics and Discovery Insights Specialist (https://trailhead.salesforce.com/en/content/learn/superbadges/superbadge_analytics_insights_specialist?trailmix_creator_id=briankessler&trailmix_id=getting-started-with-analytics) Challenge 2:

My SAQL query is now:
 
beattieSubscribers = load "Beattie_Subs";
tenuredSubscribers = filter beattieSubscribers by row(
               Tenure_Length.selection, 
               [0], 
               ["min","max"]
          ).asRange("Tenure");
churnSubscribers = filter tenuredSubscribers by 'Churn' == "Yes";
groupedSubscribers = group tenuredSubscribers by all full, churnSubscribers by all;
churnRate = foreach groupedSubscribers generate (count(churnSubscribers) / count(tenuredSubscribers))*100 as 'churnRate';

However, this results in the following error displayed on the page:
 
Function doesn't have a type check definition:

.
What is wrong here and how can/should I fix this?

Thanks?
Best Answer chosen by Brian Kessler
Emilien Guichard 40Emilien Guichard 40
Hi Brian,

Here is the code I used :

Churn Tenure step :
q = load "Beattie_Subs";
filter q by {{row(Tenure_Length_1.selection,[0],[\"min\",\"max\"]).asRange (\"Tenure\")}};q_B = filter q by 'Churn' == "Yes";
result = group q by all full, q_B by all;
result = foreach result generate (count(q_B) / count(q))*100 as 'churnRate';

Toggle widget :
"Tenure_Length_1": {
                "broadcastFacet": true,
                "label": "Tenure Length",
                "selectMode": "single",
                "type": "staticflex",
                "values": [
                    {
                        "display": "High Risk",
                        "value": "1 to 12 months",
                        "min": 1,
                        "max": 12
                    },
                    {
                        "display": "Medium Risk",
                        "value": "13 to 24 months",
                        "min": 13,
                        "max": 24
                    },
                    {
                        "display": "Low Risk",
                        "value": "25 to 36 months",
                        "min": 25,
                        "max": 36
                    }
                ]
            },


 
steve_andersensteve_andersen 
Here's my use case for a sites app:

1. Send an email out to Contacts via sf.com
2. Include a "manage my subscriptions" link in the email that has the contact id in it
3. End user clicks on that URL and lands on a sites page
4. End user is asked to enter the email address for which they want to modify subscriptions.
5. If the email they enter matches the email on the contact record, the can
6. change some settings on their contact record and hit save to commit them

I had this working in the authenticated view, but can't get sites to allow me to modify contact records as a public user. I can see why sf.com might not want to allow that. But I also don't want to make a person authenticate for this task.

So I changed things to allow the user to create a custom object that manages the subscription, and then I have a trigger on that object to update the contact record with the changes. So in effect, they are modifying the contact, but with a custom object and a trigger in between.

However, Sites won't let me do this unauthenticated. The checkboxes on my custom object don't show on the vf page. I don't get "authorization required" but the fields just aren't there.

Is Sites seeing my trigger and disallowing my public user because it knows I am going to update a Contact? Or am I screwing things up in a different way?

Here is the page:
Code:
<apex:page Controller="ext_contact_subscriptions" showHeader="False" title="Manage Your Subscriptions" >
<!-- Begin Default Content REMOVE THIS -->
<div style="margin:10px">
<h1>Manage your Subscriptions</h1>
<p>Check what you want to receive from us!</p>
<apex:form >
 <apex:outputPanel id="emailLogin" layout="block" style="margin-left:10px;"> 
  <apex:outputPanel rendered="{!AND(NOT(emailVerified),NOT(success))}" >
   <apex:outputText value="Your email:"/>
   <apex:inputText value="{!enteredEmail}" />
   <apex:commandButton value="submit" action="{!validateEmail}" rerender="emailLogin,subscriptions"/>
  </apex:outputPanel>
  <apex:outputPanel rendered="{!validationError}" layout="block">
  <br/>
   <apex:outputText style="color:#ff0000;" value="That email did not match this subscription. Try another email address."/>
  </apex:outputPanel>
 </apex:outputPanel>
 <apex:outputPanel id="subscriptions" layout="block" style="margin-left:10px;">
  <apex:outputPanel rendered="{!AND(emailVerified,NOT(success))}">
   <h2>Change your Email if you Wish</h2>
   <br/><br/>
   <apex:outputText value="Your Email: " style="margin-left:10px;"/> <apex:inputField value="{!subscription.Email__c}" /><br/><br/>
   <h2>Your Subscriptions</h2>
   <br/><br/>
   <apex:inputField value="{!subscription.Monthly_eNewsletter__c}" /> <apex:outputText value="eNewsletter"/>
   <br/><br/>
   
   <apex:outputText style="color:#666666;margin-left:10px;" value="Receive our monthly newsletter."/><br/><br/>
   <apex:inputField value="{!subscription.Action_Alerts__c}" /> <apex:outputText value="Action Alerts"/>
   <br/><br/>
   <apex:outputText style="color:#666666;margin-left:10px;" value="Receive our periodic notifications about actions."/><br/><br/>
   <apex:commandButton action="{!save}" value="Save" rerender="emailLogin,subscriptions,success"/>
  </apex:outputPanel>
 </apex:outputPanel>
 <apex:outputPanel id="success" layout="block" style="margin-left:10px;">
  <apex:outputPanel rendered="{!success}">
   <apex:outputText style="color:#666666;margin-left:10px;" value="Thanks for submitting your changes! They will go into effect immediately."/>
  </apex:outputPanel>
 </apex:outputPanel>
 <!--figure out redirect-->

</apex:form>
</div>
</apex:page>


Here is the controller:

Code:
public class ext_contact_subscriptions {
 
 public Contact contact = new Contact();
 
 public Boolean emailVerified   { get; set; }
 public String enteredEmail    { get; set; }
 public Boolean success     { get; set; }
 public Boolean validationError   { get; set; }
 public string msg       { get; set; }
 
 public Subscription__c subscription { get {return subscription;} set {subscription = value;} }
  
 public ext_contact_subscriptions() {
        contact = [select id, email,Monthly_eNewsletter__c, Action_Alerts__c from contact where id = :ApexPages.currentPage().getParameters().get('id')];
        emailVerified = false;
        validationError = false;
        success = false;
        subscription = new Subscription__c();
        subscription.Contact__c = contact.Id;
        subscription.Email__c = contact.Email;
        subscription.Monthly_eNewsletter__c = contact.Monthly_eNewsletter__c;
        subscription.Action_Alerts__c = contact.Action_Alerts__c;
    }
    
    public PageReference validateEmail() {
     //contact.email = 'steve@test.com';
     if (enteredEmail == contact.email) {
      emailVerified = true;
      validationError = false;
     } else {
      validationError = true; 
     }
     return null; 
    }
    
    
    public PageReference save() {
     
     try {
        // update contact;
       // subscription.contact__c = contact.Id;
     //   subscription.email__c = contact.email;
      //  subscription.Monthly_eNewsletter__c = contact.Monthly_eNewsletter__c;
      //  subscription.Action_Alerts__c = contact.Action_Alerts__c;
        insert subscription;
        
         success = true;
        } catch (exception e) { 
         msg = e.getMessage(); 
        }
     
     return null; 
    }
}

 and here is the trigger:

Code:
trigger subscription_to_contact on subscription__c (after insert) {
 Map<Id,subscription__c> subsToKill = new Map<Id,subscription__c>();
 List<Contact> contactsToProcess = new List<Contact>();
 for (subscription__c sub : Trigger.new) {
  Contact contact = new Contact (    
   id=sub.contact__c,
   Email = sub.email__c,
   Action_Alerts__c = sub.Action_Alerts__c,
   Monthly_eNewsletter__c = sub.Monthly_eNewsletter__c
  );
  contactsToProcess.add(contact);
  subsToKill.put(sub.id,sub);
 }
 if(contactsToProcess.size()>0){
  try {
   update contactsToProcess;  
   //delete subsToKill.values();
        } catch (exception e) { 
         system.debug(e.getMessage()); 
        }  
 } 
}

 Thanks much!

Steve


 

Best Answer chosen by Admin (Salesforce Developers) 
BulentBulent
We are planning to fix the issue related to "page not found" in the next release.
With Force.com Sites you can only make visualforce pages public (after portal authentication standard pages are supported based on portal licenses as well).

Standard controller actions would take you to the standard pages and standard pages are not enabled for anonymous access.
You can assign a visualforce page and override the actions of any object from the object details page (Standard buttons and links -> override with a visualforce page). However, this change would apply to all users not just site access.

As you mentioned, you can write a custom controller or extend the standard controller to capture the actions and redirect them to related visualforce pages.