function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amol_NikamAmol_Nikam 

custom object data edit/delete using website created in site.com

Hi all, i am the new guy to this technology i have created my demo site using Site.com of sales-force in that i have created some custom objects and i want to add/update/delete the data in to this object through the website that i have created using site.com(not force.com).so is it possible to this.if yes then how? and if no then what is the other way to do this. your help will be appreciated thanks in advance.
Best Answer chosen by Admin (Salesforce Developers) 
ManoharSFManoharSF

Try this

 

public class updateOnboarding{
    public Prospect__c oProspect {get;set;}  
    public String         prospectId {get;set;} 
      
    public updateOnboarding() {     
        prospectId = <get value from the site to query>;
        try {
            oProspect = [SELECT Id, Name, Website__c FROM Prospect__c where Id= :prospectId limit 1];
       } catch (Exception e) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, '<Custom message>'));
            return;
        }
    }

   public PageReference save() {      
        oProspect = [SELECT Id, Name, Website__c FROM Prospect__c where Id= :prospectId limit 1];
        oProspect.Website__c= <get value from the site to update>;
        update oProspect ;  
        return null;
    }

   public PageReference cancel() {
        return null;
    }
}

for delete 

 

Prospect__c[] oProspect = [SELECT Id, Name, Website__c FROM Prospect__c where Id= :prospectId]; 

try {
    delete oProspect ;
} catch (DmlException e) {
    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, '<Custom message>'));
            return;
}

 

 

 

 

 

 

 

All Answers

ManoharSFManoharSF
if its custom object then you can do all that. use 'Public Access Settings' on your site and then edit objects settings for the custom objects to give all the permissions you want.
Amol_NikamAmol_Nikam
Hi, Thanks for your reply ,but i have set the "custom object permissions" for the object that i have created and i am able to add data to these tables from my created website(using site.com and using form component of it and showing in grid) but how do i edit /delete the records from these objects from the created website itself,is it possible to do so? thanks in advance.
ManoharSFManoharSF

Try this

 

public class updateOnboarding{
    public Prospect__c oProspect {get;set;}  
    public String         prospectId {get;set;} 
      
    public updateOnboarding() {     
        prospectId = <get value from the site to query>;
        try {
            oProspect = [SELECT Id, Name, Website__c FROM Prospect__c where Id= :prospectId limit 1];
       } catch (Exception e) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, '<Custom message>'));
            return;
        }
    }

   public PageReference save() {      
        oProspect = [SELECT Id, Name, Website__c FROM Prospect__c where Id= :prospectId limit 1];
        oProspect.Website__c= <get value from the site to update>;
        update oProspect ;  
        return null;
    }

   public PageReference cancel() {
        return null;
    }
}

for delete 

 

Prospect__c[] oProspect = [SELECT Id, Name, Website__c FROM Prospect__c where Id= :prospectId]; 

try {
    delete oProspect ;
} catch (DmlException e) {
    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.ERROR, '<Custom message>'));
            return;
}

 

 

 

 

 

 

 

This was selected as the best answer
Amol_NikamAmol_Nikam
hi ManoharSF, Thanks for reply! I have created site using Site.com.I am not sure where to add your provided code to update or delete the custom objects.If i am not wrong, the provided code is a apex code.sorry for late reply.