Fixed array name to Dynamic - twig

I would like to change a fixed array name to a dynamic array name.
Within a
set item_classes = [
item.original_link.nid and item.original_link.p6 and item.original_link.in_active_trail ? 'active',
]
This works because the 'nid' and p6 are the same and unique.
Within the item.original_link array there are 19 values:
'nid' => string(3) "114" - Node ID
'bid' => string(3) "100"
'pid' => string(3) "111"
'has_children' => string(1) "0"
'weight' => string(1) "0"
'depth' => string(1) "3" - Page Depth
'p1' => string(3) "100"
'p2' => string(3) "111"
'p3' => string(3) "114" - P+Depth
'p4' => string(1) "0"
'p5' => string(1) "0"
'p6' => string(1) "0"
'p7' => string(1) "0"
'p8' => string(1) "0"
'p9' => string(1) "0"
'in_active_trail' => boolTRUE
'access' => boolTRUE
'title' => string(21) "Development.twig.html"
'options' => array(0)
I need to set the value of the item.original_link.p6 to a dynamic value of: 'p + depth'.
As in this example, the value would be item.original_link.p3.
I hope I have explained this in enough detail for someone to help or give me direction.
I have added a set variable as below:
{% set my_var = [ ('p' ~ item.original_link.depth ), ] %}
This gives me the desired dynamic variable, but when I use this in the next set as below:
{% set item_classes = [ item.original_link.nid and item.original_link.my_var and item.original_link.in_active_trail ? 'is_active', ] %}
it returns NULL

Related

Pass data to a groupLabel

I can pass data to text labels but can't workout how to include data needs mapping to a Radio group. I think I need to create a separate array for Group Labels but can't find any help on this.
Below is a snippet of my code which works fine except my attempt to pass a value to my first_life_title radio group.
I tried both groupName and tabLabel for the radio group.
array(
"email" => $toemail,
"name" => $recipientName,
"roleName" => $templateRoleName,
"tabs" => array(
"textTabs" => array (
array (
"tabLabel" => "firstlife",
"value" => $name
),
array (
"groupName" => "first_life_title",
"value" => $title
),
Jon
In the code you posted, you're specifying the Radio Group tabs within the textTabs array -- you should instead specify radioGroupTabs as a peer of the textTabs array. Here's the JSON that shows the correct structure -- notice that the radioGroupTabs array contains a groupName property as well as a radios property (which is itself an array, containing a single object to specify the radio button to select):
"textTabs": [
{
"value": "sample string 11",
"tabLabel": "sample string 19"
}
],
"radioGroupTabs": [
{
"groupName": "NAME_OF_RADIO_GROUP",
"radios": [
{
"value": "VALUE_OF_RADIO_BUTTON_TO_SELECT",
"selected": "true"
}
]
}
]

Multiple If in single filter

if [CREATION_DATE] == ""
{
mutate {
convert => [ "CREATION_DATE", "string" ]
}
}
else
{
date {
locale => "en"
match => [ "CREATION_DATE", "dd-MMM-yy hh.mm.ss.SSS a"]
target => "CREATION_DATE"
}
}
if [SUBMITTED_DATE] == ""
{
mutate {
convert => [ "SUBMITTED_DATE", "string" ]
}
}
else
{
date {
locale => "en"
match => [ "SUBMITTED_DATE", "dd-MMM-yy hh.mm.ss.SSS a"]
target => "SUBMITTED_DATE"
}
}
if [LAST_MODIFIED_DATE] == ""
{
mutate {
convert => [ "LAST_MODIFIED_DATE", "string" ]
}
}
else
{
date {
locale => "en"
match => [ "LAST_MODIFIED_DATE", "dd-MMM-yy hh.mm.ss.SSS a"]
target => "LAST_MODIFIED_DATE"
}
}'
am getting output if i have all three (CREATION_DATE,SUBMITTED_DATE,LAST_MODIFIED_DATE) in date format.If any is STRING am not getting that log file in my input.
for ex:
my input is
12-JUL-13 11.33.56.259 AM,12-JUL-13 03.59.36.136 PM,12-JUL-13 04.00.05.584 PM
14-JUL-13 11.33.56.259 AM,11-JUL-13 04.00.05.584 PM
my output will come successfully for
12-JUL-13 11.33.56.259 AM,12-JUL-13 03.59.36.136 PM,12-JUL-13 04.00.05.584 PM
but NOT FOR 2nd line
In Simple,Logstash is indexing only when three if clauses have dates.
Help me out.THanks in advance!!
The issue with your if statements is pointed out by the comments by #Fairy and #alain-collins.
if [CREATION_DATE] == ""
Does not check if that field exists, it checks if it is an empty string.
Instead you could use a regex check to see if there is any content in the field using:
if [CREATION_DATE] =~ /.*/
and perform your date filter when this returns true.
Issue is solved when i change input format.
(New Format) 11-JUL-13 06.36.33.425000000 PM,13-JUL-13 06.36.33.425000000 PM,,
instead of
(Old format)11-JUL-13 06.36.33.425000000 PM,13-JUL-13 06.36.33.425000000 PM,"",
But My ques is still open.
I posted this because this solution might be useful to some.
Thanks!!!

logstash filters: Using message timestamp in #timestamp field

currently, my doc looks like this (rubydebug output):
{
"Timestamp" => 2016-06-20 12:51:14 UTC,
"EventDate" => 2016-06-20 12:51:10 UTC,
"Message" => "Failed to create the specified culture en-AF.",
"ProcessId" => 660,
"ProviderId" => "92bd94ca-02d2-5632-8907-3c6321d43fca",
"ProviderName" => "epicuro",
"Task" => 63133,
"ThreadId" => 5100,
"Version" => 0,
"#version" => "1",
"#timestamp" => "2016-06-20T12:51:57.706Z",
"type" => "epicuroLogs",
"#id" => "epicuro.Api_2519358737299533641_FFFFFFFB"
}
I want to use the data from the "Timestamp" field as data for the "#timestamp", but I cannot figure out how to do it. It looks like #timestamp requires a string, but Timestamp is some kind of object? (notice the missing quotes). The date filter expects a string as input from what I can tell.
How do I do this?
Maybe you can try this. Hope it's what you want.
date {
match => [ "Timestamp" , "yyyy-MM-dd HH:mm:ss"]
timezone => "UTC"
}

logstash #timestemp is not updated using date filter

I have the following filter:
date {
match => [ "zeppelin_timestemp", "YYYY-MM-dd HH:mm:ss,SSS" ]
add_field => { "debug" => "timestampMatched"}
target = "#timestamp"
}
The output is:
{
"message" => "INFO [2015-08-28 13:39:06,326] ({Thread-25} ZeppelinServer.java[run]:122) - Bye\r",
"#version" => "1",
"#timestamp" => "2015-08-28T10:39:06.326Z",
"host" => "127.0.0.1",
"type" => "zeppelin",
"log_level" => "INFO",
"zeppelin_timestemp" => "2015-08-28 13:39:06,326",
"data" => "({Thread-25} ZeppelinServer.java[run]:122) - Bye\r",
"tags" => [
[0] "zeppelin_log_event"
],
"debug" => "timestampMatched"
}
As you can see the date filter passed ok as I have the "debug" => "timestampMatched" set. but also
"#timestamp" => "2015-08-28T10:39:06.326Z" is not set.
The original input is:
INFO [2015-08-28 13:39:06,326] ({Thread-25} ZeppelinServer.java[run]:122) - Bye
Any help?
Yes, it's set correctly, just to UTC. I'll bet you're 3 hours off UTC, right?
The big hint is the millisecond value - I doubt few sites generate, ship, and process a log in the same millisecond.

Docusign API - prefilling tab values on envelope created from template

I was able to successfully generate and send an envelope from template using the Docusign API. The only problem is that the tab values and not pre-populating as expected (they remain blank). Here is the relevant code based on DocuSign-REST-API-Webinar-April2013:
/////////////////////////////////////////////
// STEP 2 - Create an envelope
////////////////////////////////////////////
$data = array(
"accountId" => $accountId,
"emailSubject" => "DocuSign API - Signature Request from Template",
"templateId" => $templateId,
"templateRoles" => array(
array(
"email" => $email,
"name" => $recipientName,
"inPersonSignerName" => "Some Customer",
"roleName" => "Customer",
"routingOrder" => 2,
"tabs" => array(
"textTabs" => array(
array(
"tabLabel"=> "mmr",
"value" => "29.95"
)
)
)
),
array(
"email" => $email,
"name" => $recipientName,
"inPersonSignerName" => "Some Tech",
"roleName" => "Tech",
"routingOrder" => 1,
"tabs" => array(
"textTabs" => array (
array (
"tabLabel" => "\\*state",
"value" => "North Carolina"),
array (
"tabLabel" => "\\*city",
"value" => "Raleigh")
)
)
)
),
"status" => "sent");
All my searches for answers on support forums, documentation, etc seem to point to what I have. I have double-checked the tabLabels and they are correct and assigned to the correct role. The template contains three roles - Tech (Sign In Person), Customer (Sign In Person), Data Entry (Receive a Copy).
Can anybody spot the problem? I also tried with just "tabLabel" => "state" and "tabLabel" => "city" (i.e. without the wildcard) but same problem. Let me know if you need more info. Thanks!
Have you verified in the template that the tags are assigned to the expected recipient? Based on your code above, it looks like the tag labeled "mmr" should be assigned to the Customer role and the tags labeled "state" and "city" are assigned to the Tech. Is that correct?

Resources