Stop New Incident Record Cannot be Resolved

Jacob23
Mega Guru

Hi, I am trying to setup some logic to stop users from opening a new incident record and then closing it as resolved. We want a new incident record to only be open as "New" or In "Progress". Happy to either stop the State field from showing the options in the first place until ticket has been moved to "In Progress", or create a field alert to let them know it cannot be set as resolved from a new state.

I would like assistance with the script that would need to be used within an on client script. I could aslo do via a busienss rule but that will require the users to fill out the form and submit the ticket for the error to bounce back.

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

You can do this via an Onload script on the incident table with something like this: 

function onLoad() {
    if (g_form.isNewRecord()) {
        g_form.clearOptions('state');
		g_form.addOption('state', '1', 'New');
		g_form.addOption('state', '2', 'In Progress');
    }

}

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

8 REPLIES 8

Michael Jones -
Giga Sage

You can do this via an Onload script on the incident table with something like this: 

function onLoad() {
    if (g_form.isNewRecord()) {
        g_form.clearOptions('state');
		g_form.addOption('state', '1', 'New');
		g_form.addOption('state', '2', 'In Progress');
    }

}

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Thanks for the fast response, this helped a lot.

I dont want to fully wipe/recreate the options so I made a little adjustment to your script:

function onLoad() {
    if (g_form.isNewRecord()) {
        g_form.removeOption('state','6');
        g_form.removeOption('state','7');
        g_form.removeOption('state','8');
    }
}

This actually hides them options and they become available once you submit/save the record.

However, I am wondering what is the better option. Would removing the options from new records be a better way to go, or would creating an on cell script so if someone tries selecting the other options which are Resolved, Closed, Cancelled, an error pops up instead?

Just a note - my solution only removes them onload when the record is new (hence the if-statement) - as soon as you save or submit, those options are present again for selection. Just won't let you create a new record with a state other than New or In Progress. Either way you want to go is fine, I just elected to remove anything but the options you want. 

Personally I prefer to not have the options present, rather than throw an alert or message upon selection; if you don't want them to select those options on a new record, why show them?

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

I thought your solution might have worked that way as well.

I agree, I have gone with the options not being visible. Thanks again for the help!