How to add an attachment functionality in a service portal page?

joanmarisse
Tera Expert

I have this page to record data and I want to add an attachment functionality where users can add attachment in service portal.

Do you have an idea how to do it?

Please advise.

Thanks!

40 REPLIES 40

User145619
Giga Expert

Hi Hardik,



You can fork it in github GitHub - bhanucvbmg/CreateTicketSnow: CreateTicketSnow , forking is welcome



joanmarisse can you mark the post as solved, if your issue of attachments is solved..


Did any of you faced this error while working on this on line



$scope.fd.set('files', file);



find_real_file.png


User145619
Giga Expert

Hi Nitish,



Currently, I'm into other development, maybe with with recent upgrades the issue might be happening. So can't help much.


ngo
Kilo Contributor

Hi Bhanu



Thank you so much for your reply 🙂


the thing is that in your code you have not passed authorization parameter ,and i will be doing this on the server side , so if i add auth to your code then it will work fine i guess


can you tell me the syntax using your code where i should add it plus i used this on server side


for(var l=0;l<input.filename.length;l++)


{


if(input.filename[l])


{


var restMessage = new sn_ws.RESTMessageV2();


restMessage.setBasicAuth('xxxxx','xxxxx');


restMessage.setHttpMethod(input.method);


restMessage.setEndpoint('https://xxxxxx.service-now.com/api/now/attachment/file?table_name=sn_customerservice_case&table_sys_...


restMessage.setRequestHeader("Accept","application/json");


restMessage.setRequestHeader('Content-Type',input.type[l]);


//var fle = JSON.stringify(input.file[l]);


restMessage.setRequestBody(input.file[l]);


//restMessage.setRequestBodyFromAttachment(input.file[l]);


gs.log('File Content '+input.type[l]);


gs.log('File Name '+input.filename[l]);


gs.log('File Data '+fle);


//gs.addInfoMessage(input.file[l]);


var response = restMessage.execute();


var responseBody = response.getBody();


var httpStatus = response.getStatusCode();


gs.addInfoMessage(httpStatus);


}


}


}


the setrequestbody is not uploading/sending the file object data correctly so if you cud perhaps tell me other method as file name and type are loading correctly


I have created a separate question with further details


I am having my UAT , kindly spare some time to help a brother


Load File attachment through widget servicenow portal via public page


User145619
Giga Expert

Nitish, Mail me at bhanucvbmg@gmail.com