Call UI action server script from workspace client script

Vikram3
Tera Guru

Hi,

Below is the workspace client script which I am using on a UI action,

function onClick(g_form) {

    var fields = [{
        type: 'reference',
        name: 'u_duplicate_incident',
        label: getMessage('Duplicate Incident'),
        mandatory: true,
        reference: 'incident',
        referringTable: 'incident',
        referringRecordId: g_form.getUniqueValue()
    }];

    g_modal.showFields({
        title: "Provide Duplicate Incident",
        fields: fields,
        size: 'sm'
    }).then(function(fieldValues) {
        g_form.setValue('close_code', 'Duplicate Incident');
        g_form.setValue('close_notes', 'This is a duplicate Incident');
		g_form.setValue('short_description', "Duplicate Incident -" + g_form.getValue('short_description'));
        g_form.setValue('u_duplicate_incident', fieldValues.updatedFields[0].value);
		g_form.save();
    });
}

Right now I use g_form save() to save the form which I don't recommend to do that. I need to resolve the incident from ui action once client script job is done. 

1 ACCEPTED SOLUTION

Vikram3
Tera Guru

It worked.

Rather than calling g_form.getActionName() we can directly pass the action name.

g_form.submit('action_name');

In my case below is the final code,

function onClick(g_form) {

    var fields = [{
        type: 'reference',
        name: 'u_duplicate_incident',
        label: getMessage('Duplicate Incident'),
        mandatory: true,
        reference: 'incident',
        referringTable: 'incident',
        referringRecordId: g_form.getUniqueValue()
    }];

    g_modal.showFields({
        title: "Provide Duplicate Incident",
        fields: fields,
        size: 'sm'
    }).then(function(fieldValues) {
        g_form.setValue('close_code', 'Duplicate Incident');
        g_form.setValue('close_notes', 'This is a duplicate Incident');
		g_form.setValue('short_description', "Duplicate Incident -" + g_form.getValue('short_description'));
        g_form.setValue('u_duplicate_incident', fieldValues.updatedFields[0].value);
		g_form.submit('validate_check_duplicate');
    });
}

View solution in original post

6 REPLIES 6

Amit Gujarathi
Giga Sage

Hi Vikram ,

You can use the g_form.submit to run the server side of ui action

 g_form.submit(g_form.getActionName());

It will resolve the issue 

find_real_file.png

Please mark the answer correct / helpful if it helped you.

 

Regards,

Amit Gujarathi

Hi Amit,

Thanks. I did try that but it's not working. State is not changed. 

Hi @Amit Gujarathi , 

I want to pass a value from client ui action to server ui action may be by using g_form.getActionName().

 

Could you please help on this?

 

Thanks

Ankur Bawiskar
Tera Patron

Hi,

using g_form.save() it is working fine right?

if yes then what's the issue using that

Regards
Ankur