I want to get Screen Title and pass it into Exception Action.
1.Created Client Action
2. Get Title by Javascript
3.Need to Pass ScreenTitle in to Exception Action
Is it Possible?
Because I don't want to input the Title Name
Hi @Dilmi Amar ,
You can avoid using JavaScript by using a local variable for the screen title. For example, I use a local variable called Title to hold the screen's title. You can set its default value to whatever you need and use it wherever necessary.
Alternatively, if you prefer to get the browser title using JavaScript, you can use a JavaScript node in your action with the following code:
I attached a sample OML for both use cases.
Hi @Mihai Melencu
Thank you
You can save the Javascript output parameter to a variable in the action. That way the exception flow will have access to it.
You can try to use this Javascript code:
const pageTitle = document.title;
console.log(pageTitle);
Hi @Łukasz Kaproń
How to assign outputparameter
You can do it this way:
Now you can you Output Parameter "pageTitle"
Complementing @Nuno Reis comment...
1) Create a client action.
2) Implement the logic to get a page title. (You can use the code passed by @Łukasz Kaproń)
3) Change the funtion parameter to Yes.
4) Call the function in the title parameter of your page.
Why read the page title to use it as page title? The goal was to use it in the error message.
@Nuno Reis I think he wanted to read the title of the page, because, as we can see, @Dilmi Amar considered @Mihai Melencu answer as resolved.
Both @Mihai Melencu answer and mine achieve the same goal.
The difference is that you don't have a title set when you do document.title so you will not have the title in the function.
I would move that call in point 4 to inside the exception handler.
Ok
The platform's best practices indicate that we should avoid using JS if we have another way to solve the problem and obtain the same result, so I believe that saving it to a variable and using the variable in both places would be more appropriate.
That's why I disagree with most suggestions. It works... If nothing edits the title on runtime. And if nothing edits the title, you don't need to get it as you already know it.