I'm hoping to change the initial cursor focus to m...
# suitescript
n
I'm hoping to change the initial cursor focus to my custom field when users open an Estimate form. I've tried a few versions of this code. Am I in the ballpark to getting this to work?
function beforeLoad(context) {
var newRec		= context.newRecord;
var customForm	= newRec.getValue('customform');
if(customForm == '204'){
var form	= context.form;
var fldPageFocusHTML = context.form.addField({
'id':'custpage_page_focus_html',
'type':serverWidget.FieldType.INLINEHTML,
'label':'Page Focus HTML'
});
fldPageFocusHTML.defaultValue = '<script>focusMethod = function getFocus() {document.getElementById("custbody_opportunity_registration").focus();}</script>';
}
}
s
maybe a
pageInit
client script instead?
m
You might need to wrap in setTimeout
n
ok, i'll give these a shot today
moving to pageInit is bringing me closer. Now the cursor always stays in the custom field using the following:
fldPageFocusHTML.defaultValue = '<script>focusMethod = setTimeout(function getFocus() {document.getElementById("custbody_opportunity_registration").focus();})</script>';