Question - is it possible to start a static Translation via Flow

MateoBilandzija
Tera Expert

Hello Localization Team, I would probably need just a quick help in which Script Include i need to search which processor Script is the correct one. I want to pass through Flow Designer from a Service Request several Catalog Items for Translation to a LF Group. 

 

Simple as it is I want to pass my sysids and the target language to the processor script. Probably I will ned the Artifact to but that I can pass too. Machine Translation is currently no Option at the Customer. Any tip. Any help would be much appreciated. 🙂

 

@Alex Coope - SN  Maybe somebody from your Team 😉

 

MichaelJackson_0-1693946495732.png

 

1 ACCEPTED SOLUTION

Alex Coope - SN
ServiceNow Employee
ServiceNow Employee

@MateoBilandzija,

My first suggestion, if you change the language selection to be a reference to the [sys_language] table, filtered on the languages associated to LF setting (because hardcoded is always not ideal, if you add a new language you'd have to add it here as an option also), then you could do something like this:

In my example, I've also got my variable for which catalog item as a single reference rather than a multi-select, just because it's easier. Here is the script I used in my Record Producer (hence this is a producer script):

 

// we need to call the LFAPI to make the tasks correctly
make_tasks();

function make_tasks() {
    var lfApi = new LFTranslations();
    var result = lfApi.requestTranslations(
        "catalog_item",
        [producer.document.toString()],
        [producer.target_language.id.toString()], {
            "sourceLanguage" : "en"
        }
    );
	current.setAbortAction(true); // we actually don't want this RP to make the record due to the LF API doing all the heavy lifting
	producer.portal_redirect = "esc?id=ec_pro_dashboard"; // we need to point back to somewhere
	gs.addInfoMessage(gs.getMessage('A task has been generated and will be processed accordingly'));
}

 

 

In the lfApi, you need to parse the artifact's internal name, in this case "catalog_item", the sys_id of the document (hence why I have a single reference variable type for the catalog item) and the target language, then the API handles the rest. That code should work as is if you change your variable types,

 

*For future reference, this is just a prototype to show it is possible, no warranties / support are offered*


Many thanks,
Kind regards

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

View solution in original post

2 REPLIES 2

Alex Coope - SN
ServiceNow Employee
ServiceNow Employee

@MateoBilandzija,

My first suggestion, if you change the language selection to be a reference to the [sys_language] table, filtered on the languages associated to LF setting (because hardcoded is always not ideal, if you add a new language you'd have to add it here as an option also), then you could do something like this:

In my example, I've also got my variable for which catalog item as a single reference rather than a multi-select, just because it's easier. Here is the script I used in my Record Producer (hence this is a producer script):

 

// we need to call the LFAPI to make the tasks correctly
make_tasks();

function make_tasks() {
    var lfApi = new LFTranslations();
    var result = lfApi.requestTranslations(
        "catalog_item",
        [producer.document.toString()],
        [producer.target_language.id.toString()], {
            "sourceLanguage" : "en"
        }
    );
	current.setAbortAction(true); // we actually don't want this RP to make the record due to the LF API doing all the heavy lifting
	producer.portal_redirect = "esc?id=ec_pro_dashboard"; // we need to point back to somewhere
	gs.addInfoMessage(gs.getMessage('A task has been generated and will be processed accordingly'));
}

 

 

In the lfApi, you need to parse the artifact's internal name, in this case "catalog_item", the sys_id of the document (hence why I have a single reference variable type for the catalog item) and the target language, then the API handles the rest. That code should work as is if you change your variable types,

 

*For future reference, this is just a prototype to show it is possible, no warranties / support are offered*


Many thanks,
Kind regards

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

Dear @Alex Coope - SN , Did changed my Variables. Switched to the proposed Field Types. Entered Script -  Processed Perfectly. Everbody is Happy

Thank you