Triggering flow designer with UI ACTION

tushar_ghadage
Tera Contributor

Hi All ,

I have a requriement where on click on UI ACTION create an incident (OOB) incident record will be created 

and on the INC record in the work notes should get populate with ' Created from Interaction: number12345' 

and on the interaction record ' this is forwared to incident ' should get populate in the work notes as well .

 

for this i have ui action given below : 

var canCreateIncident = false;
if ((current.isNewRecord() && current.canCreate()) || (!current.isNewRecord() && current.canWrite()))
    canCreateIncident = current.update();
else
    canCreateIncident = true;

if (canCreateIncident) {
    var inc = new GlideRecord("incident");
    inc.initialize();
    inc.caller_id = current.opened_for;
    inc.short_description = current.short_description;
    if (GlidePluginManager.isActive("sn_itsm_gen_ai") && current.chat_summary && (current.chat_summary.toString()).length < 4000) {
        inc.description = current.chat_summary;
    }
    inc.origin_table = "interaction";
    inc.origin_id = current.sys_id;
    if (gs.getProperty("com.snc.incident.create_from_interaction.save") === 'true') {
        inc.work_notes = gs.getMessage('Incident created from Interaction {0}', current.number);
        var incSysId = inc.insert();
        if (incSysId) {
            var interactionRelatedGR = new GlideRecord("interaction_related_record");
            interactionRelatedGR.initialize();
            interactionRelatedGR.interaction = current.sys_id;
            interactionRelatedGR.document_table = 'incident';
            interactionRelatedGR.document_id = incSysId;
            interactionRelatedGR.insert();
        }
    }
    action.openGlideRecord(inc);
    new InteractionRelationshipUtil().copyAttachments(current, inc);

var flowInputs = {};
flowInputs['current'] = current;
flowInputs['interaction'] = current.getTableName();

var result = sn_fd.Flow.startAsync('from_intraction_to_incident', flowInputs);
 
where above i have triggered flow in the script 
and below are flow designer steps : 
 
Screenshot (107).pngScreenshot (108).pngScreenshot (109).png
but when i click on the UI ACTION it's not working!! 
 
can anyone please help!!
2 REPLIES 2

SumanthDosapati
Mega Sage
Mega Sage

@tushar_ghadage 

Fisrtly, why do you need a flow to be triggerred for this requirement? UI action itself can create the incident, update the comments also.

And did you put some logs and see where the script is reached?

 

Regards,

Sumanth

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@tushar_ghadage 

why are you doing the same thing again in flow?

Your UI action is doing what you want

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader