Skip to main content
Nintex Community Menu Bar
Question

JavaScript Snippet Help - Find NEXT Date in Related Model

  • July 10, 2024
  • 7 replies
  • 0 views
  • Translate

Forum|alt.badge.img+4

Apologies, I still don’t know much JavaScript, but I am sure this is something that can be addressed fairly easily. Any guidance is much appreciated.

I have a model for Case and a model for FutureAppointments, I am currently using a MODEL_LOOKUP formula to pull the Next Appointment up to the Case Table, BUT it is not a sortable column, which is what I would like to accomplish.

Because Next Appointment will always be a moving target, I am looking to create a JavaScript Snippet that can be invoked whenever a model is queried (page load, and subsequent queries - maybe through a Refresh button on the Page) - any time the snippet is invoked the snippet would loop through all Appointment__c records and find the first record in the FutureAppointments model related to the Case ID.

Assume there will be more than 1 case listed on this page, the Appointment Table is just there for reference, but would be removed. Just after a list of Cases, and the ability to sort by Next Appointment.

Did this topic help you find an answer to your question?
This topic has been closed for comments

7 replies

Forum|alt.badge.img+20

Hmmmm… another solution would be to add a Child Relationship to the Event object from the Case object. Just set the limit of records in the child relationship to 1 and sort by the date field in DESC. No snippet required. 😃

Translate

Forum|alt.badge.img+10

Jason,

Instead of a JavaScript snippet, this seems like a good solution for a trigger to update the Case with the date of the next appointment.  Then you could sort by the date without a snippet and show this field on any page.

Thanks,

Bill

Translate

Forum|alt.badge.img+20

Oh yeah! Server side. Then how about Declarative Lookup Summary Tool to set the date. Set up the sort in the same way as the child relationship.

Translate

Forum|alt.badge.img+4

Great idea, but does not work if you want the column in the table to be “sortable”.  

Translate

Forum|alt.badge.img+4

Triggers are expensive in this org.  In a call center environment adding triggers may be more costly in terms of performance and scalability.  I will keep thinking on this. 

Translate

Forum|alt.badge.img+10

Jason,

Does the update have to be real time?  You could setup a batch class that would do the update.  It has much higher limits than triggers.

This is a ‘tricky’ requirement when you want to make the column sortable.

Thanks,

Bill

Translate

Forum|alt.badge.img+20

Then server side solution would be better as the value would reside on the parent record.

Is the child record Master-Detail? Then standard Rollups.

If not, can you make it Master-Detail?

Translate

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings