Jump to content

Recommended Posts

Hi all

been trying to use the WIKI for adding prefix to the ref_num Separate Prefixes for Requests, Incidents, and Problems

Instead of using type to distinguish this we are using a custom field z_created_by_group_id which uses a UUID.

The code we are using is below.

CODE
cr::zcrprefix(...) {

string str_ref, zreportedbygroupid, zref_num;

send_wait( 0, this, "get_attr_vals",2,"ref_num","z_created_group_id");

zref_num = msg[3];

zreportedbygroupid = msg[6];

//Replace the I P R below if you want different prefixes

if ( zreportedbygroupid == "cnt:DA6554CB9B6FA14F87A671472502009A" ) {

str_ref = format("CGU%s", zref_num);

}

else if ( zreportedbygroupid != "cnt:DA6554CB9B6FA14F87A671472502009A" ) {

str_ref = format("UPGRD%s", zref_num);

}

else str_ref = format ("%s",msg[6]) + format("test%s", zref_num);

send_wait(0, this, "call_attr", "ref_num", "set_val", str_ref, "SURE_SET");

The following code executes without error, but only ever runs the Else condition of the code. The If and Else If lines are not working, I believe that we are incorrectly referencing the UUID

Share this post


Link to post
Share on other sites

Is cr.z_created_group_id a SREL to a group/contact?

If so, you code should look like :

cr::zcrprefix(...) {
   string str_ref, zreportedbygroupid, zref_num;

   send_wait( 0, this, "get_attr_vals",2,"ref_num","z_created_group_id");
   zref_num = msg[3];
   zreportedbygroupid = (string)msg[6];

   //Replace the I P R below if you want different prefixes
   if ( zreportedbygroupid == "DA6554CB9B6FA14F87A671472502009A" ) {
      str_ref = format("CGU%s", zref_num);
   }
   else if ( zreportedbygroupid != "DA6554CB9B6FA14F87A671472502009A" ) {
      str_ref = format("UPGRD%s", zref_num);
   }
   else str_ref = format ("%s",msg[6]) + format("test%s", zref_num);

   send_wait(0, this, "call_attr", "ref_num", "set_val", str_ref, "SURE_SET");
}

Share this post


Link to post
Share on other sites

msg[6] should be your z_created_group_id field, as indicated by Mikelm's code:

   send_wait( 0, this, "get_attr_vals",2,"ref_num","z_created_group_id");
   zref_num = msg[3];
   zreportedbygroupid = (string)msg[6];

Edited by prohacx

Share this post


Link to post
Share on other sites

Hi Guys

Maybe I asked the wrong question.

How do you know to use '6' or '3' ? Is there a definition of what each index of msg contains?

Is the comparison of zreportedbygroupid == "DA6554CB9B6FA14F87A671472502009A" correct?

You asked me to cast msg[6] to a string, but is putting the uuid as hex in quotes the correct syntax?

The datatype of a contact's uuid in the database is "binary(16)", ie not a string. when doing (string)msg[6], is this binary value being converted to Hex string? or something else?

Share this post


Link to post
Share on other sites

I'm not 100% sure of this, but I think a send_wait calling the get_attr_vals function asking for 2 fields to be returned will return this:

msg[0] = any error message (if any) / (if no error) length of the msg array

msg[1] = field name of the first field

msg[2] = previous value of this field (if still available)

msg[3] = current value of this field

msg[4] = field name of the second field

msg[5] = previous value of that field (if still available)

msg[6] = current value of this field

And yes, you can cast a uuid to a string, so that should work. Then you can indeed compare like Mikelm was saying.

Hope this helps...

Edited by prohacx

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.


×
×
  • Create New...