GlideDialogForm used to insert a new record in an embedded table, but how to re-use parent values?

woodyfairley
Tera Guru

I am using GlideDialogForm in a UI Action to open a popover form to insert a record into an embedded list in the parent table's form. Some of the parent form's field values are required in the related record and I would like to transfer the values in the script to the new record (presented in the popover form, see the screenshots). I know the values are being captured by the script (see the alert in test1), but the fields in the popover are not receiving the values. Any help on how to fix the code? Also, any guidance on how to achieve the desired outcome more efficiently? What are best practices for popovers?

Thank you all for your consideration of my question.

Kind Regards,

Woody

 

function addAccountingLine() {
    if (g_form.modified) {
        gsftSubmit(null, g_form.getFormElement(), "update_and_stay_agr");
    } else {
        var atableName = 'x_g_noa_agree_accs_tracker';

        //collect values from client form;
        var agreeNum = g_form.getValue('sdd_agreement_number').toString();
		//alert(agreeNum); // yep this works;
		var totCostEst = g_form.getDecimalValue('agreement_total_annual_cost_estimate');
        var fyearCode = g_form.getValue('requester_fiscal_year_code').toString();
		alert("Agreement number= " + agreeNum + "\nfiscal year= " + fyearCode); //yep this works;
        
		//Create and open the dialog form
		var aal = new GlideDialogForm('Add Accounting Line', atableName); //Provide dialog title and table name
        aal.setSysID(-1); //Pass in sys_id to edit existing record, -1 to create new record
        aal.addParm('sysparm_view', 'ACCS_tracker'); //Specify a form view
        //aal.addParm('sysparm_form_only', 'true'); //Add or remove related lists
		aal.addParm('x_g_noa_agree_accs_tracker.sdd_agreement_number', agreeNum);
        aal.addParm('sysparm_query', 'fiscal_year_code=' + fyearCode);
		aal.addParm('sysparm_query', 'tracker_number=' + g_form.getUniqueValue()); //working;
        aal.setDialogWidth(800);
        aal.setDialogHeight(780);

        aal.render(); //Open the dialog
    }
}
/*/* add the text below to the section separator if you want the button to appear on the bar, use the unique sys_id of this action:

<span> Requester ACCS Accounting Codes <button id="AddAccountingAGR_section" class="form_action_button header action_context btn btn-primary" style="white-space: nowrap" type="submit" value="2431381f1be41d109d4c422de54bcb27" onclick="var AddAccountingAGR=window.AddAccountingAGR;addAccountingLine();return false;" data-action-name="AddAccountingAGR" gsft_id="2431381f1be41d109d4c422de54bcb27">Add Accounting Line</button></span>

but you must use the unique id of your application's ui action button, to find it, use the browser's developer tools, or enable the form button for the ui action, then right-click the bottom button on the form and select "Edit UI Action" and read the sysid from the url.
*/

 

0 REPLIES 0