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
Abhijit ShrikhandeAbhijit Shrikhande 

How can I create a single row object in Salesforce?

How can I create a single row object in salesforce?

In oracle, I could do something like this for a single row table:

create table singlerowtable(lastrundate DATE);

create unique index singlerowtable_uk ON singlerowtable('1');

logontokartiklogontokartik
There is no way you can do this in Salesforce. When you create an object, it automatically creates few Standard Fields, like Name, OwnerId, LastModifiedByDate, CreatedDate etc, which basically doesnt meet what you are trying to achieve. 

Is there a business reason behind your request?
Pramod_SFDCPramod_SFDC
Hi,

You can try using Custome Settings, it also act as a object. BUt not sure, if it meets the criteria. But i believe, you cannot create s Singlr rpw object.

Regadrs
Pramod
Bhawani SharmaBhawani Sharma
Go with Hierarical custom setting. Not exactly what you are looking for, but much similar to that.
Abhijit ShrikhandeAbhijit Shrikhande
is it possible to update the custom setting each time, I run a process outside of salesforce?
Pramod_SFDCPramod_SFDC
Yes, you can perform DML operation as you do it on Objects, but you cannot store more values i believe. You need to clear it and maintain the data space.


Pramod_SFDCPramod_SFDC
Hi,

Probable, you can follow this link.

>> https://developer.salesforce.com/forums/ForumsMain?id=906F00000008y9CIAQ

Regards
Pramod
Bhawani SharmaBhawani Sharma
Yes, it would be possible to update teh custom setting from anywhere.
Abhijit ShrikhandeAbhijit Shrikhande
I am able to use the code snippet below to read the value. I am able to update the value in an instance of the custom setting, but how can I update the original value of the custom setting programatically?

LastRun__c lrc = LastRun__c.getInstance();
System.debug(lrc.Run_Time__c);
lrc.Run_Time__c = date.newinstance(1947,8, 15);  
System.debug(lrc.Run_Time__c);

logontokartiklogontokartik
you just use update statement.

update lrc;