Help with coding for listViews trigger

Posted by ceteris on 14-Jul-2015 14:12

I'm at a loss for the correct coding to add an onchange trigger to the listViews field to record which view option was selected (see screenshot).

I'd deeply appreciate any guidance.

Thanks in advance.

Posted by Godfrey Sorita on 15-Jul-2015 10:01

You can use the following code to accomplish this requirement:

$(function() {
  previousOnchange = $("select:eq(0)").attr("onchange");
  $("select:eq(0)").attr("onchange", "rbf_setField('USER', {!#CURR_USER.id}, 'View_ID', this.value, false);"+previousOnchange);
});

First, you need to create a Text field with the integration name View_ID in USER object. Then, create a Create Audit Trail Record trigger with the following properties:

  • Timing: After Update
  • On Field Change: View ID
  • Trail Template: View ID {!View_ID} has been accessed.

This should generate an audit trail containing the View ID everytime the view is changed.

Posted by ceteris on 14-Jul-2015 15:50

Thanks for the quick response.  I'm creating an audit trail of User activities (e.g., pages visited, files opened, etc.).  Using the listView page onload trigger produces only a generic "(User Name)  opened Applications List View Page"  audit trail record. My goal it to specify in the audit trail record which specific listView was chosen.  Your function works perfectly for displaying the selected listView. How can I pass this listView ID on to the audit trail trigger?

Thanks again

Posted by Godfrey Sorita on 14-Jul-2015 15:23

Using the code below, you can prepend a code to the onchange event of list view.

$(function() {
  var previousOnchange = $("select:eq(0)").attr("onchange"); 
  $("select:eq(0)").attr("onchange", "alert(this.value);"+ previousOnchange);
});

What is your objective in adding a function to the onchange event of a list view?

Posted by ceteris on 16-Jul-2015 12:10

Thanks Godfrey for the quick turnaround and flawless solution!!

John

All Replies

Posted by Godfrey Sorita on 14-Jul-2015 15:23

Using the code below, you can prepend a code to the onchange event of list view.

$(function() {
  var previousOnchange = $("select:eq(0)").attr("onchange"); 
  $("select:eq(0)").attr("onchange", "alert(this.value);"+ previousOnchange);
});

What is your objective in adding a function to the onchange event of a list view?

Posted by ceteris on 14-Jul-2015 15:50

Thanks for the quick response.  I'm creating an audit trail of User activities (e.g., pages visited, files opened, etc.).  Using the listView page onload trigger produces only a generic "(User Name)  opened Applications List View Page"  audit trail record. My goal it to specify in the audit trail record which specific listView was chosen.  Your function works perfectly for displaying the selected listView. How can I pass this listView ID on to the audit trail trigger?

Thanks again

Posted by Godfrey Sorita on 15-Jul-2015 10:01

You can use the following code to accomplish this requirement:

$(function() {
  previousOnchange = $("select:eq(0)").attr("onchange");
  $("select:eq(0)").attr("onchange", "rbf_setField('USER', {!#CURR_USER.id}, 'View_ID', this.value, false);"+previousOnchange);
});

First, you need to create a Text field with the integration name View_ID in USER object. Then, create a Create Audit Trail Record trigger with the following properties:

  • Timing: After Update
  • On Field Change: View ID
  • Trail Template: View ID {!View_ID} has been accessed.

This should generate an audit trail containing the View ID everytime the view is changed.

Posted by ceteris on 16-Jul-2015 12:10

Thanks Godfrey for the quick turnaround and flawless solution!!

John

Posted by ceteris on 17-Jul-2015 09:15

Godfrey:

How would I alter your code to use the text value (i.e., "All Applications") instead of the listId (i.e., 6839800) in the audit trail?

Thanks,

John

[quote user="Godfrey Sorita"]

You can use the following code to accomplish this requirement:

1
2
3
4
$(function() {
  previousOnchange = $("select:eq(0)").attr("onchange");
  $("select:eq(0)").attr("onchange", "rbf_setField('USER', {!#CURR_USER.id}, 'View_ID', this.value, false);"+previousOnchange);
});

First, you need to create a Text field with the integration name View_ID in USER object. Then, create a Create Audit Trail Record trigger with the following properties:

  • Timing: After Update
  • On Field Change: View ID
  • Trail Template: View ID {!View_ID} has been accessed.

This should generate an audit trail containing the View ID everytime the view is changed.

[/quote]
This thread is closed