Auto-create Note or Activity when page is loaded

  • 1
  • Question
  • Updated 11 months ago
  • Answered
Hi Skuid Community! I am trying to back into some user metrics without any coding. What I've decided I want to try to do is auto-create a note or activity on my Account whenever my Account detail page is loaded. I'm using similar auto-creation for when certain buttons are clicked, but I'm not sure how I could do this every time the page is loaded (we are overriding our standard account detail in SFDC to the Skuid page). Has anyone tried this? Any other suggestions on how to achieve something similar? Any reports built?

Basically I just want to know how many times a user lands on the Skuid Acct Detail page, and how many times they are clicking on buttons that take them back to Classic functionality.
Photo of Ryan Faust

Ryan Faust

  • 884 Points 500 badge 2x thumb
  • resourceful

Posted 1 year ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Ryan,

I don't know of any way to create a row on page load except with a snippet.  Here is a sample to get you started.  You need to recreate the snippet as 'Inline'.  You also need a model on the Task object with the Subject field selected.  Uncheck the boxes to 'Query on Page Load' and 'Create default row if Model has none'.

(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
var pageViewedTask = skuid.model.getModel('CreateTaskUponPageLoad');
var pageName = skuid.page.params.page;
        
        pageViewedTask.createRow({
            additionalConditions: [
                { field: 'Subject', value: pageName}
            ], doAppend: true
        });
        pageViewedTask.save({callback: function(result){
            if (result.totalsuccess) {
                // Get the 15-digit Id of our newly-saved George Bailey Contact,
                // which will have had its Id and other fields updated after save
                console.log(pageViewedTask.data[0].Id15);
                // Show the record
                console.log(pageViewedTask);
            } else {
                console.log(result.insertResults);
                console.log(result.updateResults);
                console.log(result.deleteResults);
            }
        }});
});
})(skuid);

Thanks,

Bill
Photo of Ryan Faust

Ryan Faust

  • 884 Points 500 badge 2x thumb
Thanks for the snippet Bill! I'll take a look this week into this and see if I can get it to work as expected :)
Photo of Ryan Faust

Ryan Faust

  • 884 Points 500 badge 2x thumb
I was able to create a note when the page loads. Basically, I created a 1-record model to look for a specific note subject line. If that was not present, then I created a model action to create the note with default text in it. If the model already had that record, then it would not kick off the model action.

Actually, I ended up not going with this option as once in a while we didn't want that specific note created. So, I used the same model methodology, but if the model didn't have any data rows in it then I presented a button that said "Create Note" and it created the note with default text to fill in. If the model had the row already in it, then I hid the button and showed the note.

No snippets needed! Thanks everyone for your help on this one.