Upload and parse an excel file in workspaces

mpmacconnell
Tera Guru

I have a requirement where the users can take an excel template and upload it to the RFC form. This would then parse the file and add the devices to the affected CI's. We need to do this in the Service Operations Workspace.

 

Currently we do have the solutions suggested to do the UI action and that works great in the standard UI. But because it uses jelly it will not work in the Service Operations Workspace.

 

Wonder if someone has done something like this in the Workspaces and how that is accomplished.

10 REPLIES 10

Is it possible that when I complete the functionality on this UI page, I will be able to close the modal?

like, perform a destroy on the workspace showframe when finished.

Hi @Guilherme Mazie ,

Yes. For this modal just have it navigate to a new page or different URL or submit with no process script and it will auto close.

For example if at the end of the last function (Client side) do something like:

window.location.href = window.location.href + "&sysparm_close_dialog=true"

 

Or if you actually have to actually submit it and have processing done in the processing script, put in logic to determine if the processing should continue or not (errors or cancel). If it needs to process something let it run the normal process, then do nothing. If it needs to cancel don't execute any processing, then do nothing. In short it will auto close in either case. You're just determining whether or not the "updates" need to run or not based on the interactivity.

Hopefully that makes sense.

@ChrisBurks 

Thanks for the answer.

I ended up going another way too. apparently works fine in cli development for now.

button custom.png

attchment open.png

VG3
Tera Contributor

Hello @ChrisBurks ,

 

If possible could share the workspace client script of that UI action like how to pass the current sysid to UI Page and set current number in UI Page field ?

 

I tried in someways , but it didn't works for me

 

Any suggestions on that part ?

 

Thanks

Hi @VG3 ,

 

The following is how I understand the g_modal.showFrame() api works.

The property "url" if populated tells the modal to render an iframe and use the value of that url as the value for the src attribute to that iframe element.

With that information then the next course is to build the parameters into that url.

   var sys_id = g_form.getUniqueValue(); //current
    var assigned = g_form.getDisplayValue('caller_id');
    var state = g_form.getDisplayValue('state');
    var number = g_form.getDisplayValue('number');
    g_modal.showFrame({
        title: 'My Workspace UI Action/UI Page Test',
        url: 'uptest.do?sysparm_sys_id=' + sys_id + "&sysparm_assigned_to=" + assigned + "&sysparm_state=" + state + "&sysparm_number=" + number,
        size: 'lg',
        height: '800px'
    });

 

From here, build the UI page to pull in those parameters on the url and parse them to get the values.

HTML Markup in UI Page

<style>
		h2 {
			margin-bottom: 20px;
		}
		.row .col-md-6:first-child {
			width: 180px;
			display: inline-block;
			text-align: right;
		}
	</style>
		
	<section class="container">
		<article>
			<h3>Information Gathered from the Incident; Parsed by Jelly</h3>
			<p class="row">
				<span class="col-md-6">Incident sys_id: </span>
				<span class="col-md-6">${RP.getParameters().sysparm_sys_id}</span>
			</p>
			<p class="row">
				<span class="col-md-6">Incident Number: </span>
				<span class="col-md-6">${RP.getParameters().sysparm_number}</span>
			</p>
			<p class="row">
				<span class="col-md-6">Caller: </span>
				<span class="col-md-6">${RP.getParameters().sysparm_assigned_to}</span>
			</p>
			<p class="row">
				<span class="col-md-6">State: </span>
				<span class="col-md-6">${RP.getParameters().sysparm_state}</span>
			</p>
			<label>
				<h3>Upload and parse</h3>
				<input type="file" name="Upload File" id="upload_file" multiple="true" />
			</label>
			<p id="details"></p>
		</article>
	</section>
	
	<button id="cancel" type="button" class="btn" onclick="closeIt()">Cancel</button>