After Update Event

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Is there any way to "refresh" a model/screen after a drop-down box option has been changed?  I have a template box that holds an image of the item displayed in a drop-down.  I'd like the image to change when the drop-down is changed, but the user has to save the model before it will update.  Any JS options maybe?
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You can trigger an action sequence on the model.  One of the initiating events on the model is "row in Model updated"  This could trigger a requery of the model where your image is.

You need to be careful because this initiating event means that if any field in the model is changed the requrey will be triggered.  A workaround we have used is to isolate that picklist field into its own model,  where conditions keep it in the same record as the primary object model.  This means the action sequence is not triggered by changes that are happening in the other model. 

That should work.. 
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
I've tried this a bunch of different ways, but I can't get it to work.
I've tried viewing the image as a TEMPLATE and a FILE COMPONENT, but the image doesn't change when I change the drop-down option.  The event is definitely being triggered, but the "requery" doesn't update the image.  Does the page need to be fully refreshed?
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Hey Scott,

Random thoughts:

Browser caching issue? One idea is to use jQuery to update the SRC attribute and append a timestamp. For example,

var d = new Date();
$("#myimg").attr("src", "/myimg.jpg?"+d.getTime());

Regards,
Irvin