How to create a record from UI action

Supriya25
Tera Guru

Hi All,

 

Some one please help me how to do this.

 

I have "Create Corporate" button in Incident Form when I click on that button it has to redirect and Open New corporate form to fill all the details and to submit. after submitted corporate form ,  Again it has to redirect to incident record and show that create "corporate" record number in Incident form of Corporate reference field.

 

Supriya25_1-1669105113946.png

 

 

 

 

7 REPLIES 7

Rana5
Tera Expert

Create a reference field on the Corportate form and pass the Incident sys_id using action.setRedirectURL. Once you have one way link, the other way link can easily be created using BR.

 

Regards,

Rana

mdash
Giga Guru

Hi Supriya,

This can be easily solved using GlideDialogForm. You don't have to redirect to another form, submit and again redirect back to current. 

Create the UI Action:
Name: Create Corporate
Table: incident
Form Button: true

Client: true
Onclick: showCorporateForm()
Script: 

 

 

function showCorporateForm() {
    //Get the table name and sys_id of the record
    var tableName = '<YOUR TABLE NAME>'; 
    var sysID = -1;

    //Create and open the dialog form
    var dialog = new GlideDialogForm('Create Corporate', tableName, populateIncident); //Provide dialog title and table name
    dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
    dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
    dialog.render();

    dialog.render(); //Open the dialog

    function populateIncident(action, sys_id, table, displayValue) {
        g_form.setValue('u_corporate', sys_id); // This is the reference field on your incident form.
    }
}

 

 


When the user clicks on Create Corporate, it will open a popup form where you can fill up the details and submit, it will auto populate the Corporate field with the sys id of new record. Then you can click on Save.

You can mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards

Hi ,

 Your Code is working sucessfully, really happy for your help with details code.

 

Supriya25_0-1669121123123.png

 

 

But Client want to redirect to that Corporate New Page , he want to fill and Submit there only then back to current record.

 

Is it Possible? if Yes, any kind of KB articles , solutions can you provide please .

Hi Supriya,

Are there any other ui actions available on the new corporate form such as Save, Update, Cancel, Delete, etc?

Because from Incident UI action, we can redirect to new/partially filled Corporate form, but from there what UI action is clicked and the subsequent result can not be controlled from here. 

For reference, you can look at the Create Normal Change UI Action on Incident form. Here when you click on it, a new Change form is presented with some values filled. If you click on update, it will send you back to incident, but if you click on Save, it stays there. Makes sense?

You can mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards