var newRecords = [];
var a = new sforce.SObject("MyObj__c");
a.id ="{!SOQL_Report__c.Id}";
a.Last_Time_Executed__c = new Date().toISOString();
newRecords.push(a);
result = sforce.connection.update(newRecords);
Natalia, your question actually answered my question, which was how to get the Community ID to my Apex controller for a Visualforce component. I think you have answered your own question, which is to create a base controller that all of your site controllers will extend, so that every page can have access to the Community ID.
The base controller would look something like the following:
/*
* Base class for all custom Visualforce controllers, containing common
* utility methods such as getting and setting page parameters
*/
public virtual with sharing class CustomController {
/*
* @return the Community ID for the community context in which the
* controller is operating, based on the location at which
* a particular Visualforce page is requested
*/
public Id getNetworkId() {
return Network.getNetworkId();
}
}
Then, just make sure all of your controllers for the site in question extend this base controller.
/*
* Controller for the SiteProfile page
*/
public with sharing class SiteProfileController extends CustomController {
/* ... */
}
Best Answer
If you don't mind having the date in there: