Jump to content
Sign in to follow this  
eoliva

presavetrigger() for Change Orders

Recommended Posts

Hi, I am attempting to make some fields mandatory whenever a status transition is performed on a Change Order, and am using the code listed below.

The code works for my requests/incidents, but can't get it to work for Change Orders. I know that it triggers when the status is changed to ENGTSKEST because it pops up the window.

However, it does not flag the field as mandatory as it did for requests/incidents. I could be missing something, and I'm hoping someone could highlight that to me.

function preSaveTrigger()
{

    // Make the GROUP and IMPLEMENTER field mandatory when the status is set to ENG TASK ESTIMATION.
    if (document.forms['main_form'].elements['SET.status'].value == "ENGTSKEST" )
    {
        is_required = 1;
        popupWithURL('http://http://pqdvuc01:8060/wl/login.jsp', 1, 1);
    }
    else
    {
        is_required = 0;
    }
    z_setMandatory(document.forms['main_form'].elements['SET.z_task_implementer'].id, is_required );
    z_setMandatory(document.forms['main_form'].elements['SET.group'].id, is_required );


    return true;
}

//
//  This function sets or clears the mandatory flag for a field
//
function z_setMandatory(idToSet, is_required)
{
    var fields = "";

    for (var i = 0; i < _dtl.fieldToValidate.length; i++)
    {
        fields = fields + ", " + _dtl.fieldToValidate[i].id;
        if (_dtl.fieldToValidate[i].id == idToSet)
        {
            _dtl.fieldToValidate[i].is_required = is_required;
        }
    }
}

Thanks as usual for all the tips!

Cheers,

Erwin

Edited by Erwin

Share this post


Link to post
Share on other sites

Hi.

Tried to test your code, but it doesn'te really work in any way, at least at my side.

When you say, it's working in incidents, what happens if the status is ENGTSKEST?

You get a popup, ok. But what else? Is the ticket jsut not saved and stay in edit mode or ´do you get also the red border around the mandatory fields?

What version are you working with?

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...