Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to convert Workflow Script To Flow desihner

MalikB
Tera Contributor

Hi! 

 

In a case of a conversion from workflow to flow designer , in the first step there is a Script to set RITM fields :

current.short_description = current.variables.ritm_short_description.getDisplayValue();
var related_offering = new GlideRecord('u_m2m_service_offering_catalog_item');
related_offering.addQuery('u_catalog_item', current.cat_item);
related_offering.query();
if (related_offering.next()) {
    current.service_offering = related_offering.getValue('u_service_offering');
    var service_offering = related_offering.u_service_offering.getRefRecord();
    current.assignment_group = service_offering.getValue('u_support_level_n1');
    current.business_service = service_offering.getValue('parent');
}

 And in the Catalog Task :

task.assignment_group = current.variables.sctask_assignment_group.getValue();
task.short_description = current.variables.sctask_short_description.getDisplayValue();

How to convert the workflow (begin -> Run Script (set RITM fields) -> Approval Action -> Catalog Task -> X=Set values -> end) to a flow designer? 

8 REPLIES 8

@Ankur Bawiskar Is it like that? however i cat find what i need for the conditions that was scripted Capture d’écran 2025-03-10 à 10.15.44.pngCapture d’écran 2025-03-10 à 10.18.03.png

@MalikB 

in your Lookup you need to add condition using your catalog variable

Like this u_catalog_item == Requested Item->Item

AnkurBawiskar_0-1741613466345.png

 

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

@Ankur Bawiskar 

 

Ive changed the flow using an assignment rule to get service offering values fields and ritm short description like this : 

var cat=current.cat_item;

	var gr1 = new GlideRecord("u_m2m_service_offering_catalog_item");
	gr1.addQuery("u_catalog_item", cat);
	gr1.query();
        if (gr1.next()){
                        current.service_offering=gr1.u_service_offering.sys_id.toString();
                        current.business_service=gr1.u_service_offering.parent.sys_id.toString();
                        current.assignment_group=gr1.u_service_offering.u_support_level_n1.sys_id.toString();
} 


current.short_description = "MARS"  + " - " + current.ritm_short_description.getDisplayValue() ;

The original in the workflow was : 

current.short_description = current.variables.ritm_short_description.getDisplayValue();
var related_offering = new GlideRecord('u_m2m_service_offering_catalog_item');
related_offering.addQuery('u_catalog_item', current.cat_item);
related_offering.query();
if (related_offering.next()) {
    current.service_offering = related_offering.getValue('u_service_offering');
    var service_offering = related_offering.u_service_offering.getRefRecord();
    current.assignment_group = service_offering.getValue('u_support_level_n1');
    current.business_service = service_offering.getValue('parent');
}

and system properties to get assignment group i

 

Capture d’écran 2025-03-16 à 21.18.50.png

 

i just need to get short description now right like in the workflow : 

task.short_description = current.variables.sctask_short_description.getDisplayValue();

 if you see a mistake or can help to convert what needed from workflow to flow 

MalikB
Tera Contributor

@Ankur Bawiskar i cant find the the variables to make the conditionsCapture d’écran 2025-03-10 à 10.15.44.pngCapture d’écran 2025-03-10 à 10.18.03.png