How to use the values calculated in ServiceNow Notification activity script inside the message body? - servicenow

I wish to create notification message which needs to have the name of the recipient and some other values calculated in the notification activity script in a workflow. How do I use them inside the message body?

Hmm, would it make sense to just create an event where you include the values you need into one of the parameters? Then in the notification you can access the parameters and parse the values in anyway you want.
Something like:
var jsonstr = '[{'name' : 'value'}, {'name' : 'value2'}, {'name' : 'value3'}]';
gs.eventQueue('my.event.example', current, jsonstr, '');
Just make sure that the parameter is a string. You can create a JSON, convert that into a string and then parse that in your email script.

Related

How to take each string in an array and use it in a url in rspec?

I am writing a test in rspec. I want to clean up the test by grabbing all the ids from the events that were created and using them in my delete api url.
So I get an array of all my events (objects)
my_events = #api_actions.Get(
'Send a request to get my events.',
'/endpoint_url',
nil
)
my_cal = my_events.result
Then I loop through the result array and collect each event object's id and put the ids into a new array:
event_id_array = my_cal.map{ |event| event.id }
Now I want to loop through event_id_array and delete each event using those ids, but I am not sure how to do that. I need to grab each event id and put it in the url below:
#api_actions.Delete(
'Delete the event',
"/events/#{event_id_goes_here}",
nil
)
What do I need to do to get each event id from the array to go through the delete action?

Change request parameters name - Laravel

is there anyway to change the parameters name of request in laravel?
something like :
//we have $request['email'] in our request object and we need to change the name of it NOT VALUE
ChangeParaName($request['email'],$request['password']);
//now instead of $request['email'] we have $request['password'] with same value in our request object and just name of parameter changed
You could do this:
$request->merge(['password' => $request->email]);
This will simply put a key called password in $request with value of $request->email.
The email key would still be there.
There are two steps. First of all, you have to merge then you have to unset or remove the old request parameter name.
First merge the request
$request->merge(['password' => $request->email]);
Remove request parameter name
$request->request->remove('email');
I think it will help you.

How to create a complex object in ESQL

I would like to create the following JSON object in ESQL and put it on the SET OutputRoot.JSON.Data. How do I do that?
{
"active" : [ {"name" : "test"},
{"name": "test2"}]
"inactive" : [ {"name" : "test3"}]
}
There is a standard procedure for IIB developers who want to output a specific format of XML/JSON:
Use a text editor to create the document that you want to output
Create a simple message flow that parses that document.
On the FileInput node (or HTTPInput, if you prefer) set the Domain to 'JSON'
Make sure that the second node is a Trace node with Pattern set to '${Root}'.
Put the example JSON through the message flow
Examine the Trace node output, paying special attention to the field type on each node
Write ESQL that produces an identical message tree under OutputRoot.JSON.Data
The below snippet demonstrates how to create JSON you need:
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- Create JSON domain
CREATE LASTCHILD OF OutputRoot DOMAIN 'JSON' NAME 'JSON';
-- Create root Data field
CREATE FIELD OutputRoot.JSON.Data;
DECLARE OutMsg REFERENCE TO OutputRoot.JSON.Data;
CREATE FIELD OutMsg.active IDENTITY (JSON.Array)active;
SET OutMsg.active.Item[1].name = 'test';
SET OutMsg.active.Item[2].name = 'test2';
SET OutMsg.(JSON.Array)inactive.Item[1].name = 'test3';
RETURN TRUE;
END;
Also you can read more information about work with JSON here Manipulating messages in the JSON domain and here Creating or transforming a JSON message by using a message map

Cant get CanonicalForm for LUIS List entity in LuisResult/EntityRecommendation

Is there any way of getting the CanonicaForm in the C#-code after an intent? The LuisResult contains EntityRecommendation(s) but no info about which canonicalForm/sublist, just the written entity/synonym in EntityRecommendation.Entity and the name of the WHOLE List Entity in EntityRecommendation.Type.
Assume "MyEntity" is a List entity, and one of its normalized values is "Check Out" with a synonym of "checkout"
If LUIS returns the synonym ("checkout") as the entity, the normalized value ("Check Out") can be retrieved as follows:
bool isEventType = result.TryFindEntity("MyEntity", out EntityRecommendation entityRecommendationEventType);
if (isEventType)
{
stringSynonym = entityRecommendationEventType.Entity;
stringNormalized = ((List<object>)entityRecommendationEventType.Resolution["values"])[0].ToString();
}
There is no way to retrieve this from LUIS. The only way you can do this is to export the list from LUIS and store it in your bot. You can do this via the JSON file exported from LUIS.

Laravel custom request validation

i have been trying in create check on form validation on laravel
i need to query input with date and check more than check with many messages
like
if(){
$this->errorSchema->addError($error, $name); //symfony 1 way
}
how and where should i do that i have been thinking in creating custom validtaion but it returns true or false i need the date in the query to display like "this place is used for user XXX" XXX is data i got in the query
i want to return multi error if some record exist like
$resultset = 'select person form events where date < "some date"';
if ($resultset[enddate] > 'somedate'){
my error message should be "you cant add this event as $resultset['person'] overlape in this date "
}elseif($resultset[startdate] > 'somedate'){
i need here to return deffrent error message like "start date is overlapping with resultset['person']"
}
i am using requests class in laravel so please recommend me a method to override or any other way to this in laravel
thanks in advance
You can try to SELECT data which you'd like to return, your "XXX", from table by user's input.
Simple SELECT *** FROM table WHERE smth = user's_input;
If it return smth, you can just add it to your validator such as: "this place is used for user".$smth;
Else (if nothing returned, you send to user your default answer.)
Also if you add more code it will be easier to help you :)

Resources