Skip to main content

I have a Calendar and I am trying to write a Javascript Snippet so that when the Calendar item is clicked, users will be redirected to another URL instead of seeing a popup. 

var params = argumentss0],$ = skuid.$;
var models = skuid.model.map();
var Appointments = models.Appointments;
var TheAppointment = Appointments.getFirstRow();
var Id = Appointments.getFieldValue(TheAppointment,‘Id’);
window.location = ‘/apex/skuid__ui?page=AppointmentDetail&Id=’ + Id;


Unfortunately getFirstRow() does not work in this situation, because no matter which Calendar Item I click I get the same Record ID. 

How do I fix the Javascript so that it knows the ID of the Calendar item I am clicking on?

Thanks!

This should do it:

var params = arguments[0];
window.location = ‘/apex/skuid__ui?page=AppointmentDetail&Id=’ + params.row.Id;

Event On-Click Snippets are handed several arguments, but the most helpful ones for you here are:

- event: the row that was clicked in the event source’s model (same thing as row)
- row: the model row corresponding to the event that you selected
- eventSource: the Event Source object for the event you clicked on
- model: shortcut reference to the event source’s model



Awesome!  Thank you so much!


Zach, another question related to this snippet.    I want to redirect to different URLs based on the User’s profile name.  How do I assign the Users Profile Name to a variable so I can use it in the IF statements?

Here is what I have so far, but no luck, and it’s using ID’s which is not ideal:

var params = argumentsa0];var profile = skuid.utils.userInfo.profileid;
if(profile == ‘00e1a000000RWZdAAO’ || ‘00e1a000000RcH5AAK’){
window.location =  ‘caminoportal/apex/skuid__ui?page=AppointmentDetail&Id=’ + params.row.Id;
}
else{
    window.location =  ‘caminoportal/apex/skuid__ui?page=AppointmentManager&Id=’ + params.row.Id;
}



The reason this isn’t working is due to camel-casing of variable names — profileId with Id capitalized instead of profileid … it’s always the small things 🙂

If you are on Banzai, you can (and should!) use profileName instead:

var params = arguments 0];
var profile = skuid.utils.userInfo.profileName;
if((profile === ‘Skuid Ninja’) || (profile === ‘Christopher Nolan Fanboy’)){

} else {

}


Works like a charm.  Thanks again!