I'm trying make 2 different field required depending on which category is used when creating/updating a ticket.
For this I tried to make use of the Post_Validate way to prompt an error message if the field is null.
chg::z_validate_category(...) {
string zmsg;
if((category == "SIGSCLVM" || category == "SIGSCWVM" || category == "SIGSCPM") && (is_null(project))){
zmsg=format("Project is REQUIRED");
set_error(1);
set_return_data(zmsg);
return;
}
else if((category != "SIGSCLVM" || category != "SIGSCWVM" || category != "SIGSCPM") && (is_null(z_ttessa_code))){
zmsg=format("TTESSA CODE REQUIRED");
set_error(1);
set_return_data(zmsg);
return;
}
}
When I do this. The first condition prompts the correct error message.
Category = "SIGSCLVM"
Project = <Null>
TTESSA Code = <Null>
Error: "Project is Required"
But when I do fill up the Project field. I get prompted by the 2nd error message.
Category = "BSGSL"
Project = "Test Project"
TTESSA Code = <Null>
Error: "TESSA CODE is Required"
It seems like it still tries to go through the 2nd error message even if it doesn't meet the requirement
But when I do:
Category = "BSGSL"
Project = <Null>
TTESSA Code = <Null>
Error: "TESSA CODE is Required"
It prompts the correct error message so the 2nd condition is correct.
As I have been going around this for a time, I did also tried to use switch but same results. It still run through the 2nd error message still.
chg::z_validate_category(...) {
string zmsg;
int error_msg;
if((category == "SIGSCLVM" || category == "SIGSCWVM" || category == "SIGSCPM") && (is_null(project))) error_msg = 1;
if((category != "SIGSCLVM" || category != "SIGSCWVM" || category != "SIGSCPM") && (is_null(z_ttessa_code)))error_msg = 2;
switch (error_msg)
{
case 1:
zmsg=format("Project is REQUIRED");
set_error(1);
set_return_data(zmsg);
return;
break;
case 2:
zmsg=format("TTESSA CODE REQUIRED");
set_error(1);
set_return_data(zmsg);
return;
break;
}
}
Im quite at lost what could be wrong with the spl code I made.