Service Portal: Embed Form Widget in a Modal

kurtbell1
Giga Expert

Hi there - I am trying to embed a form widget within a modal widget.   In this case it's a "New" button and I want to have the button bring up a Modal to create a new Task.   The modal is coming up fine and it looks like the Form widget is embedding, but its not rendering the Form.   I just get a "Record not found" message.   I'm sure it has to do with the "widgetInput" parameter below, but based on the documentation i saw on Git it looks like I'm doing this correctly (even thought I'm clearly not).

Does anyone have a suggestion for what I'm doing wrong?

find_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

sndangibbard
Mega Guru

Hi Kurt,


What you have there is perfectly correct from a technical perspective, after a bit of investigation I've discovered that the sys_id parameter is not actually getting passed over in your widgetInput object - for some reason it is getting stripped out! You can verify this yourself if you clone the Form widget and modify it to log out the $scope data.



So the best solution I can find is to follow that route, if your requirement is only to open a new form then make a clone of the Form Widget and call that clone in your modal instead. In the Server script of your cloned Widget, force it to use -1 as its sys_id


sys_id.PNG



Hope this helps despite it not being a particularly elegant solution!


View solution in original post

5 REPLIES 5

ravi0508
Tera Contributor

Below code has worked for me.  Essentially instead of "-1" being a string, I made it an integer...

if(action == 'addRule'){
	spModal.open({
		title: "Rule Details",
		widget: "widget-form",
		widgetInput: {sys_id: -1, table: '<My Table Name>'}
	}).then(function(){
		alert("Rule Added);
	});
}