How to have the MRVS info display in service portal once submitted by requestor?

Si Min
Giga Expert

Hi All,

Obviously my widget for the service portal has been customized and I not sure where to fix to get it display out in the service portal in requested RITM item and approval screen.

Thanks.

1 ACCEPTED SOLUTION

Please find the link here for the community article.

Hope this helps 

 

Mark this response as correct if that really helps

 

Thanks,

Siva

View solution in original post

9 REPLIES 9

Hi Siva, 

I managed to get it done with below script but if the table contains more than 1 entries, then the email will not work. 

Could you help on pointing me where goes wrong? 

Thanks. 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
	
	var mrvs;
	var rowCount;
	var ritmGR = new GlideRecord('sc_req_item');
	if (ritmGR.get(current.sys_id)) {
		mrvs = ritmGR.variables.book_details; //multi row variable set info
		rowCount = mrvs.getRowCount();
		gs.log(rowCount, "rowcountHarish");
		gs.log(mrvs , "harish");
		//gs.addInfoMessage(mrvs[0].standard_it_or_non_standard_it + " => standard or non standard" + mrvs[0].asset_type_requisition + ":: asset type");
	}
	
	if(rowCount == 1){
		gs.log("row count is 1","oneHarish");
		//template.print('<table border="1px solid black">');
		//template.print( "<tr bgcolor='#FFFFFF' align='center'>" );
		
		template.print('<table border="1px solid black" style="font-family:Arial">');
		template.print( "<tr bgcolor='#ddd'align='center'>" );
		template.print("<td style='text-align:center' colspan='10'><strong>Book Details</strong></td>");
		template.print( "</tr>" );
		
		template.print( "<tr>" );
		template.print( "<td><center><b>Type</b></center></td>" );
		template.print( "<td><center><b>Title </b></center></td>" );
		template.print( "<td><center><b>Subtitle</b></center></td>" );
		template.print( "<td><center><b>Author / Editor</b></center></td>" );
		template.print( "<td><center><b>Year of Published</b></center></td>" );
		template.print( "<td><center><b>International Standard Book Number</b></center></td>" );
		template.print( "<td><center><b>Publisher</b></center></td>" );
		template.print( "<td><center><b>URL</b></center></td>" );
		template.print( "<td><center><b>Estimated Price (SGD)</b></center></td>" );
		template.print( "</tr>" );
		
		var mvrs = current.variables.book_details;
		var ritm = current.getUniqueValue();
		var rowCount2 = mvrs.getRowCount();
		for (var i = 0; i < rowCount2; i++) {
			var row = mvrs.getRow(i);
			template.print( "<tr>" );
			template.print( "<td><center>" +row.type + "</center></td>" );
			template.print( "<td><left>" +row.title + "</left></td>" );
			template.print( "<td><left>" +row.subtitle + "</left></td>" );
			template.print( "<td><left>" +row.author_editor + "</left></td>" );
			template.print( "<td><center>" +row.year_of_published + "</center></td>" );
			template.print( "<td><left>" +row.international_standard_book_number_isbn + "</left></td>" );
			template.print( "<td><left>" +row.publisher + "</left></td>" );
			template.print( "<td><left>" +row.url + "</left></td>" );
			template.print( "<td><center>" +row.estimated_price_sgd + "</center></td>" );
			template.print( "</tr>" );
		}
		template.print('</table>');
		
	}})(current, template, email, email_action, event);

Ops, I think I got it, is because of the row count. 

Thanks for spending time reading this post. 

below line will always give you one row if sysid found in the sc_req_item table. 

ritmGR.get(current.sys_id)

 

 

If my response has helped you in achieving the requirement , mark my response as correct and close the thread.

 

Thanks,

Siva

Harsh Vardhan
Giga Patron

i think this thread has same question and same script so little correction has been on below thread.

 

https://community.servicenow.com/community?id=community_question&sys_id=ffb6cdfddb83fb4c190dfb243996...

 

Kindly mark my answer as correct and close this thread.