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
sales4cesales4ce 

Any way we could check if record is opened for first time after it got created.

 

Hi,

 

Is there any way we could check if the record is opened for first time after it got created?

 

Thanks in advance!

 

Sales4ce

EnthEnth

Only way I can think is to have some javascript on the page layout (via VisualForce or SControl) that performs an update of the record to set a 'view count' or similar custom field.

EnthEnth

The s-control version would be something like this, if updating a custom field called Viewed__c on an Opportunity:

 

 

 

<script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script> 

<script language="javascript"> 

try{
 var result = sforce.connection.query("SELECT Id, Viewied__c FROM Opportunity WHERE Id = '{!Opportunity.Id}' "); 
 var updOpp = result.getArray("records"); 

 // Update the view count
 updOpp[0].Viewed__c = 1;

 var saveResult = sforce.connection.update(updOpp); 
}
// Check for errors
catch (err) { 
    alert (err.description); 
}
</script>

 

 

SteveBowerSteveBower

Do you mean "opened for editing", or "opened for viewing"?  (And I presume we're only talking about "opened via the UI" as opposed to exported, used by some other trigger, etc.)  -Steve

sales4cesales4ce

infact, i have a use case which led me to think that way of seeing whether it is opened by a particular user or not.

 

The use case is:

 

we have a ideas portal and within an idea we have categories of the idea . for each category we have some users.

 

so, whenever an idea is posted in that category, we need to send an email alert to the users with in that category.

 

If the users assigned to that category do not open the idea for 2 weeks i need to send an email alert again.

 

Hence i was thinking if there is a way we could track when a record is opened for first time.

 

is there any better way we could do it for this use case?

 

Thanks,

Sales4ce

sales4cesales4ce

Hi Enth,

 

thanks for your reply!

can we check if a particular opened the record or not?

 

Thanks,

Sales4ce

Shubham guptaShubham gupta
Hi sales$ce,

You can find the number of counts "SELECT COUNT(Id)
FROM Account
WHERE LastViewedDate != null".

Please mark as it the best answer.

Thanks!