SP: Creating a new record in a widget using widget-form with details passed in

Hope_MSTS
Tera Contributor

I'm having trouble creating a new record in the Service Portal. I've added a button to a widget that, when clicked, calls this:
Client script

c.newButtonClicked = function(widgetId, widgetInput) {
		var url = top.location.href;
		var submittalId = new URLSearchParams(url).get("sys_id");
		widgetInput.submittal_request = submittalId;
		spModal.open({
            widget: widgetId, 
            widgetInput: widgetInput,
	    buttons: [],
	    shared: {scope: $scope}
        }).then(function(){
            action.setRedirectURL(targetPageID);
        })      
}

is called in the HTML with this:

HTML

 <div ng-if="c.options.hide_new == 'false'">
    <button class="new-record" ng-click="c.newButtonClicked('widget-form', {'table':options.table,'sys_id':'-1'})">New</button>
</div>

 

I'd like to fill in the "submittal_request" reference field on the new Comment object with the submittalId I pass in to the widgetInput object. Is there some way that I can make the base Form do this, or do I need to clone it?

1 REPLY 1

SanjivMeher
Kilo Patron
Kilo Patron

The last response in this thread may help you.

 

https://www.servicenow.com/community/developer-forum/pass-additional-parameters-to-embedded-default-...

 


Please mark this response as correct or helpful if it assisted you with your question.