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

How to create a data record from a "trigered" event

I would like to create an account triger so when a user access an account a triger will place a record in the SF database or simply write to a local file the Account Name.


Would someone please assist me as I know nothing about adding trigers or Apex code.




Message Edited by Ira on 01-21-2010 10:34 AM

Being hosted in cloud will not write to a local file on your C: drive. You can create a local file of data by exporting the account data from account object using a report or list view etc .


For writing the the account record in a different table you can use a trigger on account object. Look at Apex Code developer guide


I am just wondering why would you want to save the same account record in a different table ?


I am trying to ascertain which account the user has accessed.


I'm running a VB program that will have access to SF via the API Tool Kit.


I need to know (from VB) which account the user has accessed so I can gather phone numbers to be used to dial out.


So, when a user accesses an account I need some sort of trigger to occure to write some data (AccountID, UserID,...) into a table I will be monitoring. If can ascertain which account and which user, I can pop a app with the phone numbers that the user can use to start a callout.



You now have provided a much better description of the problem you are trying to address :-)


So, here is what might help you to accomplish this.


Step 1 - Create a webservice e.g. callRecords.createEntry( string  accountId, string userID) . This web service will receive an account Id and will query the account object to get the account and user record. This account record you can write in a separate table or just update a custom field on the account object itself (e.g. last accessed date and who accessed etc).


Step 2-  I am assuming you have a Visualforce page to display accounts records to your user. In that VF page you can write onload javascript function which calls the above mentioned web service and passes the account and user id 


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


windows.onload = createAccessRecord 


function createAccessRecord(){

//call the webservice  and pass the account Id field

  callRecords.createEntry( string  accountId, string userId);




Hope that helps.. 




Thanks. Now we are on the same page.


I know the solution you have suggested will work, if I knew how to impliment it.


Please forgive me as I am not very knowlageable in APEX or JAVA. I do know VB and some HTML


Obviously from within VisualForce, one can obtain the current Account ID the user is accessing. How, I don't know.


Like HTML, the isn't the APEX/JAVA code is running locally? 


If so, can this information be passed to a locally running applicaton? Is so, my prayers will have answered.

The vb app will be running on the local computer, so this would be perfect. I would not have to create a record.

Once my local app gets the AccountID, it will be able to query the database to get the telephone numbers. 


If not, if would need some serious help in modifying/add the webservice & how to add the APEX/Java to the user's VisualForce.


Thanks for all your help.






Nope...the Apex code does not run locally on your computer instead your code is hosted on platform. Therefore, your VB code running on a local machine has no ability to access the SFDC records directly. You will have to use APIs or build your own Apex web service. has excellent documentation and sample code for VB and .Net integrationVB .  Since you know VB, the sample VB code will bring you up to speed quickly.


Drop me an email at sayeed dot faruqi at gmail dot com  if you would like to discuss this further.