Only show annotation on new record forms?

perkinsarm
Mega Guru

We would like to provide some instructions, but only on a new record form. There is a use case to allow some users access to the regular form but in specific cases we want to make sure that appropriate record producers are used. We added an Annotation to the form containing instructions and links to those record producers. The annotation isn't appropriate when a record already exists.

Is there a simple way to remove the Annotation from the form if the record is not new?

I've seen proposed solutions where you try to hide it with CSS hacks but they leave a space where it would normally appear.

Is there a possibly better alternative solution?


Thanks,

Brad

1 ACCEPTED SOLUTION

perkinsarm
Mega Guru

The solution I found was to avoid using an Annotation altogether. Trying to hide it with the View Rules solution would require too much effort. Hiding it by manipulating the DOM was theoretically possible, but I couldn't make a Client Script to do that.   Instead I removed my annotation and simply created an On Load client script that uses g_form.addInfoMessage(same annotation text) to the same effect.


function onLoad() { // Display instructions and links if the form is displaying an existing record. if(g_form.isNewRecord()){ g_form.addInfoMessage([html that mimics the desired annotation]'); } }


View solution in original post

10 REPLIES 10

Chuck Tomasi
Tera Patron

Hi Bradley,



You should be able to do this with a second view (looks like the original default form, but with the annotation) to force people to that view when the record is new.



Create a view with the same layout + annotation


Create a View Rule. Check Advanced. Create a script like the following


(function overrideView(view, is_list) {



  // Add your code here


  answer = 'default';


  if (current.isNewRecord)


      answer = 'newView';   // set the new view to answer


})(view, is_list);




NOTE: Untested


Reference:


Create a view rule


Chuck,



This looks like it might be the   right way to do this. Can I quickly copy a view with all of its dependencies intact? Recreating the current View manually would take a lot of time and risk missing something. Also, this is a form view and not a list. I don't know if that matters?



I'll follow-up on the results.



Thanks


Hi Bradley,



There's no easy way to copy a view. Sorry. You'll have to create it manually.


In that case, I'll need to look for another solution. This is a complex form. Recreating it accurately will take too much time.