function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steven Vawdrey 13Steven Vawdrey 13 

Apply a time-delay when clicking Submit

We use a custom Sales Order object that submits data to NetSuite, our company's ERP. It has been requested that we provide the ability to add a delay to the submission. For example, all required data has been provided in the sales order but the user does not want to actually submit the order for a few days, weeks, etc. Instead of setting a task reminder or tracking sales orders in a list view, our users would like to be able to provide a date/time, click Submit, and have the sales order officially submit on the date/time identified. The date and time fields could either be individual custom fields on the sales order or better yet, fields that display in a pop-in when the Submit button is clicked (defaulting to current day time).

Is this possible?
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Do you want to submit a record on a specific date/time?
Steven Vawdrey 13Steven Vawdrey 13
The date/time would be different for each sales order/user. Some might want to wait 5 days before the order is submitted, some may only want to wait 24 hours. Different for each order. So, I'd like to be able to provide a date field and a time field for when the order would officially be submitted. Hope that makes sense.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
You can use time based workflows and create action to submit the records on the user specific date/time.
Steven Vawdrey 13Steven Vawdrey 13
What field would I use for the workflow? The Submit button?
SalesFORCE_enFORCErSalesFORCE_enFORCEr
What happens when you submit a sales order? There must be some status or something which you will update. So, when the date/time is populated, trigger the time based workflow.
Steven Vawdrey 13Steven Vawdrey 13
Got it!! I will work on this and let you know how it goes. Thanks so much for the quick response!!
Steven Vawdrey 13Steven Vawdrey 13
Still working on this issue. This is what I'd like to see happen, if possible.

We have a custom Submit Order button on our custom Sales Order object that pushes order data to NetSuite, our ERP. I've created a Time-delayed Submission? checkbox and a Submit Sales Order On date field. If the Time-delayed Submission? checkbox is checked, and the Submit Sales Order On date entered is > TODAY(), I'd like the Submit button to change the status of the Sales Order to Pending Submission (this would be a new status value).

The current Javascript code on the Submit Order button is:
{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")}

(function() {
function unescapeHtml(safe) {
return safe
.replace(/&/g, "&")
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&quot;/g, "\"")
.replace(/&#039;/g, "'");
}

var errors = sforce.apex.execute('OrderServices','submitOrder',{'orderID':'{!NetSuite_Sales_Order__c.Id}'});


if(errors.length)
{
var errorMessage = errors.join(' ');
alert(unescapeHtml(errorMessage));
}
else
{
window.location.reload();
}

})();

Do I create a time-delayed workflow that sets the sales order status to Pending Submission. Or do I use Process Builder to somehow submit the order on a future date without having to manually click the Submit Order button? I'm having a hard time thinking through this and any help you all might have would be so appreciated!

Steve