Regex Table Lookup not working with Click Element variable - google-tag-manager

I have created a regex lookup table variable to output text based on the Click Element containing a specific string. However, the variable appears as null despite the string definitely being in the Click Element. Can anyone help?
Here is my regex lookup table variable
Here is the debug window showing null (the Action field is where the regex table variable should populate)
Here is the full tag that contains the variable
Here is the trigger for the tag
I have tried various different strings from the Click Element, without luck.
The trigger for the tag is based on the same string, and the trigger works, which only adds to my confusion.
I feel like the problem must be obvious, but I'm at a loss.

I struggled with this as well until I realized that "Click Element" is actually an object, not a string. It's based on gtm.element in the datalayer.
So, in order to do this you'll need to create a custom datalayer variable that more accurately targets a specific child key.
To see what I mean, open a link in a new tab and then type in datalayer into your browser console, and press enter. You'll see something like:
3:
event: "gtm.click"
gtm.element: a#mylinkclass.my-class.something.else
accessKey: ""
ariaAtomic: null
ariaAutoComplete: null
ariaBusy: null
ariaChecked: null
ariaColCount: null
ariaColIndex: null
etc....
Screenshot of chrome inspector console showing datalayer children
So, then you'll have to create custom variable to target the key you'd like. For example, a datalayer variable that you create with gtm.element.className would return my-class something else for link Link Text.
Using this method I was able to create a Regex lookup table just like you're trying to do.
Here's a post that goes into some more detail on some of the above:
https://www.analyticsmania.com/post/click-element-variable-in-google-tag-manager/

Related

select date field from SQL datasource in appmaker based on drop down value

I can not post a comment to another question that exists out there, so I am asking my own question. I have a drop down, that consists of "employee name". I want a date box to auto-populate based on the result of the name selected. I.E. John Smith is selected and his DOB is 01/02/1987, I want this second box to return 01/02/1987.
Things I have tried:
Server side script function, calling function -- RESULT: Function not found
Client side script function, Calling function -- RESULT: function found, but can't find references to datasources
On another post, someone recommended doing options in the dropdown to being #datasources.Events.items and then the onChangeEvent being widget.root.descendants.DateBox1.value = newValue.Date;
I have tried this, however, I can not stop the "options" at "items". I am required to proceed through to items.projects.fieldName. Since I am selecting the fieldName on requirement, the newValue isn't returning the date based off that field. It simply says "undefined value"
How should I populate one date box based on the result set of the dropdown box?

In App Maker, can you fake valueIsRecord with a dropdown field?

In App Maker, what is the simplest way to achieve the same result with a dropdown box that you can with a suggest box, which can return the whole record when you make a selection giving you the ability to assign associated record values to other fields on the page?
Consider a data model with three fields, (Code, Description, and Severity). Add a dropdown box to select the Code. Have the selection, (probably using onValueChange or onValueEdit), write the selected Code's Description to a label field beside the dropdown box. The Code's Severity will also be used to affect the style in some way like background color or something, but for this answer, merely assigning the value to a scripting variable will be good enough. It's the record value access and assignment mechanism I am after.
Clarification: This data model will not be the page's datasource. It is a secondary reference table used for assigning a code to a ticket. You can also assume that a record value will be written to a field in the page's datasource as well.
I would appreciate the simplest low code solution as we will have non-programmers attempting this. Thanks.
As long as you leave your value binding on the dropdown blank the following should work:
Set the options binding to:
#datasources.YourDatasource.items
You may want to consider changing the 'Names' binding to be the projection of a particular field in this datasource otherwise the values showing in your dropdown will only be the 'keys' from this datasource.
Then in your onValueEdit event you will gain access to individual fields like this:
var item = widget.datasource.item;
item.YourFieldToEdit1 = newValue.YourOtherDatasourceField1;
item.YourFieldToEdit2 = newValue.YourOtherDatasourceField2;
That would probably be the simplest way.

Capture a current value from dropdown widget based on a 'one relation end'

[google-app-maker]
New to AppMaker and never done coding before, so please excuse the question if obvious or I'm trying to do the impossible.
App Maker -
I have a page,
on the page is a 'Create' Item form,
and then on another panel on same page, a dropdown from another model thats generated from a 'one relation end' and using a none related datasource or model to the model I am updating.
Like me my code is very simple(as learning) Im just trying to update a field within the model the form is creating a new item in with the current dropdown value, that comes from a different datasource and based on a 'one relation end' from two other tables.
Table:
Id | date | action | user | note | theValue |
'did it' X
I have applied the code within my 'Submit button' on the form, to keep it very basic.
widget.datasource.item.action = 'did it'; // Works fine
widget.datasource.item.theValue =
widget.root.descendants.Sites_dropdown.value; // this fails ( error below )
widget.datasource.createItem();
But I get the following error.
ERROR --
Type mismatch: Cannot set type sites record for property newValue. Type String is expected.
at assets_move.Content.Form1.Form1Footer.Form1SubmitButton.onClick:2:33
I can see by the error, its not passing as a string, not sure if this is because its a dropdown with a different datasource on another panel, or Im using the wrong binding to get the value.
Any help much appreciated.
The problem is likely that the value binding you have in the property editor of the Sites_dropdown widget is not a string, make sure it is a string binding and it should work. Also, with a binding, you will not need this anymore:
widget.datasource.item.theValue =
widget.root.descendants.Sites_dropdown.value;
Since the binding will handle that for you.
You may also have the Options property of the widget set to a record, and thus the value is also a record. Make sure options is also a string and not a record.

getting textfield output partly unvisible

In a Drupal content type a need to get the output of a field partly unvisible. These are bank account details, the IBAN.
Normally the field shows 1234567. I need to get xxxx567. I need to show only the last 3 numbers/letters.
Also I need this output in field edit form.
On the display end you could change the output using a simple PHP function in the theme template by grabbing a substring of the field's last three digits and concatenating it with "xxxx" before printing.
You might also consider doing this at the formatter level by using the 'custom formatter' module perhaps?
https://drupal.org/project/custom_formatters
To do this on the edit screen is trickier. I suppose you could do a hook form alter to use PHP to change the field value, but I am afraid you will rewrite the field value when you save the node with the 'xxxx' instead of the real data.
I wonder if it would make sense to 1.) hide the actual field, 2.) create a dummy field that displays the text formatted as "xxxx567" to the user, and 3.) write some javascript that populates the hidden field with the visible field's value if it is changed. Presumably the form would still throw values if the hidden field did not meet formatting requirements.

Lookup field appears as numerical values instead of text on Access report

I am trying to create a report putting a field called contact which has the name of a person. This name is linked directly to another table where I keep all the contacts.
For some strange reason, when I include this name (which in query view displays as the name of the contact), instead of the name appearing, the unique ID number is shown on my report.
As mentioned in the article cited in the above comment, you can use a Combo Box control on your report to do the lookup for you. To see how this can be done, create a new report based on the table containing the lookup field, then drag and drop that field onto the report. That will create a Combo Box control with properties that look something like this:
Row Source: SELECT [Clients].[ID], [Clients].[LastName] FROM Clients;
Bound Column: 1
Column Count: 2
Column Widths: 0";1"
You could use a similar Combo Box control on your actual report to display the client's name rather than their numeric ID value.
Another alternative would be to change the Control Source of the report's Text Box control to have it do a DLookUp() on the table. If the lookup field is named [client] then changing the Control Source of the Text Box to something like
=DLookUp("LastName","Clients","ID=" & [client])
would also work.
I wanted to add to the great answer by Gord:
When using a "web" database (started in Access 2007 I think), you cannot change a report's fields to ComboBox style, nor can you use DLookUp(). (web databases lack a ton of features)
The workaround for this, if you want to create a Web-Report that uses lookup fields, is to create a Web-Query first based on your Web-Table (all the Web-* stuff has a www planet icon over the logo, if you create a new Web-DB in Access 2007+ you'll see what I mean)
So, instead of Table -> Report, you'll have to do W-Table -> W-Query -> W-Report.
Then, the only thing you need to customize to get the data right is the W-Query. Start by trying to reproduce the look in the query to match what you want users to see in the report. Note that here in the query, lookups will work fine (instead of the unique ID's, you get field names like you want). However, this will not carry over to the report. To do that, you gotta get the actual text field name you want into the query:
You should already have one table in your query; start by adding the table that your first lookup field points to. For example, the table I want to print is called Stock_Boards, and it has a lookup field called PCBID_lookup that points to the table Stock_PCBs.
Since you're using lookup fields, there should already be a relationship line between the two tables when you add the second one. If there isn't, something has gone horribly wrong.
Now, see how that line connects two fields on the two different tables? For example, I've got my PCBID_lookup field on my Stock_Boards table, which connects to the ID field on my Stock_PCBs table. If I created a report from this now, PCBID_lookup would be a number, a number that correlates to the ID of a record on Stock_PCBs.
To fix it, I will add the name field I want to show up on the report. In my example, that happens to be a Part Number, rather than the ID. I add the PartNumber field from my Stock_PCBs table to the query, and remove the PCBID_lookup field of the Stock_Boards table from my query.
Since PartNumber is what I want to show up on my report, it effectively replaces the original field (PCBID_lookup)
Repeat for all lookup fields you want in your report.
I had 1 more: I removed the Status field of the Stock_Boards table (which was an ID/Lookup) and added the 'Status' field from the Status table (which was the actual text name)
When finished, your query should look exactly how you want the data to appear, without any special tricks or asking Access to do something unnatural. Save your query, and create a web-report from it. Done!

Resources