SC Catalog Item widget submission question

yundlu316
Kilo Guru

Our team cloned the ootb SC Catalog Item widget and is wondering how this widget actually submits the record producer.  We see the client script for triggerOnSubmit, but don't see how this onClick function actually submits the record producer.  

$scope.triggerOnSubmit = function(timeout) {
		if ($scope.options.isServiceWorkspace && $window.frameElement) {
			var workspaceParams = {};
			workspaceParams.sysparm_parent_table = $window.frameElement.getAttribute('parent-table');
			workspaceParams.sysparm_parent_sys_id = $window.frameElement.getAttribute('parent-sys-id');
			$scope.data.workspaceParams = workspaceParams;
		}
		$scope.data.sc_cat_item.item_action = "order";
		$scope.data.sc_cat_item.quantity = c.quantity;
		$scope.$evalAsync(function () {
			if (g_form) {
				$scope.submitting = true;
				if (!spScUtil.isRegexDone($scope.data.sc_cat_item._fields)) {
					$scope.submitting = false;
					$scope.validating = true;
				} else if (!g_form.submit()) {
					timeout = timeout || 1000;
					$timeout(function () {
						$scope.$broadcast('$sp.service_catalog.form_submit_failed', {action_name: 'submit'});
					}, timeout);
				}
			}
		})
		return false;
	}

 

Can anyone provide some direction on where the actual submission is being called?

5 REPLIES 5

Dylan Mann1
Giga Guru

I believe it's done through g_form.submit(). Try a code search for that and see if you get a bit more context.

we were kinda thinking along those lines.  We see (!g_form.submit())...does if(g_form) means submit?

It's hard to say for certain. Here's where g_form is actually set in the client script:

find_real_file.png

 

I think g_form listens for the form submission, then in your case is most likely calling the getOne() function. I think that function is where the creation is happening.

interesting....do you happen to know where all the validations occur (e.g. making sure mandatory fields are filled in, etc.?)  

We want to clone this ootb widget and then flag true when all the valiations return true and vice versa.  We have a custom submit button and want those rules to trigger and prevent a submission if any of the rules are not fulfilled...