Jump to content
Sign in to follow this  
trish

preSaveTrigger being ignored

Recommended Posts

I created two fields zshow in the category table that is a checkbox and zdata which is just a string field.

I need the zdata field to be required when the zshow field is checked.

Here is my code

<PDM_IF "$prop.form_name_3" == "edit">

function preSaveTrigger ()

{

var zshow_value = document.main_form.elements ["SET.$args.category.zshow"].value;

var zdata_value = document.main_form.elements ["SET.zdata"].value;

if zshow_value == "1" && zdata_value == "" ;

{

alert ("Data must be filled in");

return false;

}

else return true;

}

</PDM_IF>

I have added this code saved and published and when I open a new incident it just seems to ignore the code.

Share this post


Link to post
Share on other sites

Did you add only the code fragment you posted to the page or you have additional code on the page for the 2 new html elements ? Only adding those custom fields to the schema will not make them appear on your detail page - I think both 'var's will yield 'undefined' if you only added the code fragment above to the page.

Share this post


Link to post
Share on other sites
Did you add only the code fragment you posted to the page or you have additional code on the page for the 2 new html elements ? Only adding those custom fields to the schema will not make them appear on your detail page - I think both 'var's will yield 'undefined' if you only added the code fragment above to the page.

I added the PDM_MACRO code to detail_in.htmpl to show the zdata field.

The zshow field is part of the detail_pcat.htmpl so the category that need the zdata field can be selected.

I could not do this with properties because after the zdata is entered it needs to be only visible to a certain role.

Share this post


Link to post
Share on other sites

Your code will not work in this form - SET.$args.category.zshow does not exist in the 'detail_in.htmpl' unless you add it manually, that's why I asked.

You have to understand that even if you added the field on the Category object, it is not added to the 'detail_in.htmpl' form - you need to add it yourself and furthermore, you'll need to populate the field using JavaScript when the user selects the Category.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...