Draft feature for Record Producer

Abhishake1
Giga Contributor

Hi Developers,

Has anyone implemented a draft state feature for Record Producer,if yes then please share the way or is it possible to have this for record producer or not.

Regards,

Abhishek

19 REPLIES 19

Mark Roethof
Tera Patron
Tera Patron

Hi there,

What actually is functionally what you want to achieve with a draft Record Producer?

I mean, there are already possibilities like active true/false, show on portal true/false, attaching to a service portal and category true/false. Would these already be enough?

Or is it like draft, someone has to approve the record producer, etc..

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Abhishek,

I don't think out of the box this feature exists. you would require some custom script to handle this

check links below

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

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

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Utpal Dutta1
Mega Guru

Hey Abhishake,

I've implemented a Draft feature in Record Producer for Portal. Not for Record Producer in UI. In UI when i create a new Button on Record Producer using UI Macro, I was not able to give functionality to that button same as Submit button on Record Producer. But when I implemented same using Portal then i was able to add a Save as Draft button and also make it work.

What my Save as Draft button does is it saves the record in Draft state and It does't check for mandatory fields. It avoids mandatory and saves the record in Draft state in Change table.

 

How i implemented it using portal??

 

I first cloned (sc_cat_item) widget and did some following Changes in it:

 

HTML changes:

At line no 156: Used below code to add a button name as Save as Draft.

 <button ng-if="::c.showOrderNowButton()" tabindex="0" name="submit" ng-disabled="submitting || submitted" ng-click="triggerOnSaveasDraft()" class="btn btn-primary btn-block">Save as Draft</button> 

 

Client Script Changes:

 

After (triggerOnSubmit()) function I've added one more function;

 

$scope.triggerOnSaveasDraft = function(timeout)
{
var fields = g_form.getFieldNames().toString().split(",");
for(var i =0;i<fields.length;i++)
g_form.setMandatory(fields[i],false);
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 (!g_form.submit()) {
timeout = timeout || 1000;
$timeout(function () {
$scope.$broadcast('$sp.service_catalog.form_submit_failed', {action_name: 'submit'});
}, timeout);
}
}

})
return false;
}

 

That's it!!! Also create a State named as Draft in your Table. In my case I've created a State choice named as Draft.

If you need any more assistance then please let me know.

 

If it helps then please mark my answer Correct and Helpful.

 

Thanks and Regards:

Utpal Dutta

 

Hello @Utpal Dutta your solution is very nice and it works well I just have some questions if you don't mind helping me out.

In my case, I am trying to submit a demand and I want the user to set the demand to draft if they like then click submit when they are ready. At the same time, I would like them to be able to when they are completing the form if they like to submitted right away they should be able to.

So, the functionality I am looking for are:

1- when the form is completed two buttons will show up. Save as Draft and Submit. If they click submit the Demand state will be set to Submitted, if they click Save as Draft the state will be set to Draft.

2- If the user clicks Save as Draft and the Demand state is set to Draft, they should be able to make changes to the record click Save as Draft then changes should apply and the state should stay the same but if they click submit the changes will still apply and the state will change to Submitted.

Your help will be greatly appreciated, Thank you in advance.

find_real_file.png