I even tried following and got the same result:
cr::zcr_verify_attach(...){
string zmsg;
int zaccesstype, zattmnt_length;
uuid someuser;
send_wait(0, top_object(), "call_attr", "cnt", "current_user_id");
someuser = msg[0];
logf(SIGNIFICANT, "someuser = %s", someuser);
send_wait(0, top_object(), "call_attr", "cnt", "sync_fetch", "STATIC", format("id = U'%s'", someuser), -1, 0);
object lstUser, objUser;
lstUser = msg[0];
send_wait(0, lstUser, "dob_by_index", "DEFAULT", 0,0);
objUser = msg[0];
zaccesstype = objUser.access_type;
logf(SIGNIFICANT, "zaccesstype = %d", zaccesstype);
if (zaccesstype == 10002 || is_null(zaccesstype))
{
send_wait( 0, this, "get_attr_vals",1,"attachments.length");
if (msg_error()) {
logf(ERROR, "error getting attachments.length for %s %s - %s", type, ref_num, msg[0]);
return;
}
zattmnt_length = msg[3];
if (zattmnt_length == 0) {
zmsg=format("You must provide an 'Attachment' in order to create new %s.", type.sym);
set_error(1);
set_return_data(zmsg);
}
}
}
Original Message:
Sent: 02-17-2020 05:09 AM
From: Brian Mathato
Subject: Re: How to make attachment mandatory for Tickets
Perhaps you can use this sample code as the base?
http://forum.servicedeskusers.com/forums/topic/22998-attachment-required-for-some-request-area/?tab=comments#comment-52878
You'd need to twig the spel-code to remove if statement in the beginning and probably alter the error message appropriately.
------------------------------
Kind Regards,
Brian
Original Message:
Sent: 02-14-2020 06:12 AM
From: Davor Dimeski
Subject: Re: How to make attachment mandatory for Tickets
Can you please be more detail or set some example.
Original Message:
Sent: 03-02-2015 08:58 PM
From: JAMES CAMPBELL
Subject: Re: How to make attachment mandatory for Tickets
This is very similar to the problem 'how to make an affected CI mandatory for a change order', and my approach would be the same in either case. For attachments, add a POST_VALIDATE trigger in site\mods\majic, calling a spel function that gets 'attachments.length' for the ticket and sets an appropriate error message if attachments.length <= 0. Alternatively, if you have a status transition that you can tie this requirement to, then hand-code a site-defined condition macro that tests 'attachments.length' and use that in the status transition.
Regards,
James