The CreatorCon Call for Content is officially open! Get started here.

How to open the mobile camera using script in serviceportal

Sasidhar Lekka1
Tera Contributor

Hi,

How to open the Mobile camera to take pictures in service portal , can anyone help me in this 

Regards,

Sasidhar.

9 REPLIES 9

@JanneHjorth 

Hi Janne,

I apologize for the late response but I've been a bit busy.
Instead of adding the functionality to the "addAttachment", you would probably just replace it with a custom button. (It's probably what you meant but just making sure)

I wrote this a couple of years ago so depending upon which attachment button you're thinking of switching out, the attachment button might be embedded within a widget that's displaying the form such as the new catalog widget.
In this case you could clone that widget or make a "wrapper" for that widget where you basically can do some slight manipulation of the OOB widget without cloning.

In this way you can embed your custom add attachment button.

 

Community Alums
Not applicable

I use your code and created camera widget but how i can save that image into ServiceNow   database  table.

 

help me!!

Hi Harshal,

If you have made it to capturing the base64 encoded image one way you can attach it to a record is use the Attachment API REST service).

Or use the GlideSysAttachment API (server side only). To get the data to the server side in the widget use the .server.get() API method sending with a custom property and of course the data.

For example:

scope.take_snapshot = function(){

		var snap = takeSnapshot();
                scope.server.get({"snapShot": snap});

		// Show image. 
		image.setAttribute('src', snap);
		image.classList.remove("hide");

		// Enable delete and save buttons
		delete_photo_btn.classList.remove("hide");
		download_photo_btn.classList.remove("disabled");

		// Set the href attribute of the download button to the snap url.
		//download_photo_btn.href = snap;

		// Pause video playback of stream.
		video.classList.add("hide");
		video.pause();
	}

Note: I haven't tested this as I don't have the setup any longer. This post was done 4 years ago.

 

I hope this helps.

Hi @ChrisBurks , we wanted to implement the solution provided by you for using camera widget. Can you please let us know how we can make this camera work as QR scanner. Is it possible?

Thanks in advance.

Can you tell me if I want that if I clicking on the UI Action Button on form after clicking the button the camera should on the it capture the live image and save to particular user record using RITM NO on Desktop