Field with attachment in a table

Sai Santhosh Ch
Tera Contributor

Hello,

                I have a requirement where I have to create a Field named     " Description 1 " such that it should look something like this,

- >         Description 1         #       (Consider '#' as attachment icon).

So, I want a field so that users could write the description of attachment and attach the file beside the description in a table.

But, There is no field type attachments . I know that there is an icon on top right of each form provided by servicenow, But I want something like this to a field.

Please Help

Thanks in Advance.

1 ACCEPTED SOLUTION

amaradiswamy
Kilo Sage

Hi Santhosh,



You can create a link to add attachment by using *annotations


1. Add annotations to selected slush bucket


2. in the annotation text enter the below code (you can change/remove the styling based on your requirement).



<div id="wrapper" style="color:#000000; line-height: 25%;height:0;text-align:left">


<a id="swamy.attachment" onclick="saveAttachment('incident', '${sys_id}');"><img src="images/icons/attachment.gifx" />Add atatchments here</a>


</div>



find_real_file.png



Regards,


Swamy


View solution in original post

17 REPLIES 17

Yep... just make a Client Script (onSubmit) with the following:



function onSubmit()


{


      if (checkForAttachments() == false)


      {


              // Make sure dirty form still works


              g_form.submitted = false;



              //Abort the submission


              return false;


      }


}




function checkForAttachments()


{


      var sysid = g_form.getUniqueValue();


      var attach = new GlideRecord('sys_attachment');



      attach.addQuery('table_sys_id', sysid);


      attach.query();



      if (attach.next())


              return true;


      else


      {


              alert("You are missing attachments.");


              return false;


      }


}






dev201
Tera Contributor

Hi,



This is working fine. But I am not able to see the attachment in the form.


The attachment is getting attached for the annotation which I created..But where it is going..Please help??


Hi Debashish



It should be saved at the top of the page. It will save to the actual record.