how to implement save as draft for a catalog service request

PrithviK
Tera Contributor

I have a requirement where i need to implement a "save as draft" functionality for my catalog item.I have created a save as draft button using UI page on my catalog item and wrote some script to generate a service request.But i don't want that service request to proceed further on workflow for any approvals as it is in a save draft until the user submits it .Please suggest some solution.

6 REPLIES 6

nitin_kumar
Mega Guru

Hi,


You can write an If condition or a wait for condition in the workflow to achieve this.


Create a wait for condition activity with the required condition.


Screen Shot 2016-07-20 at 3.56.57 PM.png


Hope this answers your question


Thanks,


Nitin.


PS : Mark the answer as like, helpful or correct based on the impact


blahblah
Kilo Contributor

Hi


I have similar requirement like creating a button as save as draft on cart and Request should be in draft state. Will you able to help?


PrithviK
Tera Contributor

Hi Ashish



We have implemented this through a UI page.


Create a UI page where you need to write scripts as below and refer to this UI page from your variable of   type UI page.



find_real_file.png



HTML



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


  <table>


  <tr width="25%">


  <td width="50px">


  <button id="order_now" title=""


  class="request_catalog_button_with_icon btn cat-btn btn-primary"


  onclick="orderNowSaveAsDraft()"


  type="button" href="#" style="float: left;">Save As Draft</button>


  </td>


  </tr>


  </table>


</j:jelly>



Client Script:



function orderNowSaveAsDraft() {


  //setting variable Set as draft to yes


  g_form.setValue('isthisdraft','yes');//isthisdraft is a variable which is hidden on catalog form and is of   type singleline textbox


  //alert('Clicked draft-'+g_form.getValue('isthisdraft'));


  g_cart = new SCCart();


  var m = g_form.catalogOnSubmit();


  if (!m)


  return;


  var item_guid = gel("sysparm_item_guid");


  if (item_guid)


  item_guid = item_guid.value;


  var catalog_guid = gel("sysparm_catalog");


  if (catalog_guid)


  catalog_guid = catalog_guid.value;


  var catalog_view = gel("sysparm_catalog_view");


  if (catalog_view)


  catalog_view = catalog_view.value;


  g_cart.order(gel("sysparm_id").value,"1", item_guid, catalog_guid, catalog_view);



}




I hope this might help you:)


Rohant Joshi2
Kilo Expert

Hi Prithvi,



I am not sure if you can hold on catalog page saying "save it as a draft", reason being the catalog page itself is a UI Page and the variables you design gets render on the UI Page.



What I would suggest is you can allow the end user to submit the request using catalog which will create a request and then you can keep your request editable until "Submit Request" UI Action on the request is clicked.


Once the UI Action is clicked that is a final submission after which you disable the variable editor.



Let me know if this works.



Thanks.


Rohant Joshi.