I made a form so that users can register their email address for a contest. Im using a powermail form and someone told me to use dbEntry to do this, but im not sure how to do it. This is my code so far:
plugin.tx_powermail_pi1{
dbEntry{
tt_address._enable = TEXT
tt_address._enable.value = 1
tt_address.email = TEXT
tt_address.email.value = ????
}
debug.output = all
}
Ive been told to activate _enable to enable the data insertion. But now I dont know how to access the field value of the form. I probably should use the template id, which is ###UID71###, but I have no idea how.
According to the official documentation, you can do it this way:
plugin.tx_powermail.settings.setup {
dbEntry {
# enable or disable db entry for tt_address
tt_address._enable = TEXT
tt_address._enable.value = 1
# write only if field email is not yet filled with current value
# (update: update values of existing entry)
# (none: no entry if field is filled)
# (disable: always add values don't care about existing values)
tt_address._ifUnique.email = update
# fill table "tt_address" with field "pid" with the current pid (e.g. 12)
tt_address.pid = TEXT
tt_address.pid.data = TSFE:id
# fill table "tt_address" with field "tstamp" with the current time as timestamp (like 123456789)
tt_address.tstamp = TEXT
tt_address.tstamp.data = date:U
# fill table "tt_address" with field "name" with the value from powermail {firstname}
tt_address.name = TEXT
tt_address.name.field = firstname
...
}
}
I also found an (older) forum post (in German) with examples that use data from the user session:
# table "tt_address" with field "last_name" is the value from powermail (tt_content uid 88) field uid18 (###uid18###)
tt_address.last_name = TEXT
tt_address.last_name.data = TSFE:fe_user|sesData|powermail_88|uid18
Related
I created a Form for requesting new student Google account. I want a Sheets Script to email the person who submits the Form the new account information, which is created via a formula on a "Results" sheet.
function Notification() {
// Send email notice for accounts
var lastRow = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Results").getLastRow();
var range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Results").getRange("A" + lastRow);
if (range.getValue() !== "") {
return lastRow;
} else {
return range.getNextDataCell(SpreadsheetApp.Direction.UP).getRow();
var AccountName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Results").getRange("H" + lastRow);
var Password = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Results").getRange("I" + lastRow);
var PW = Password.getValue();
var Account = AccountName.getValue();
// Fetch the email address
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Results").getRange("G" + lastRow);
var emailAddress = emailRange.getValues();
// Send Alert Email.
var message = 'Account Request - Account Name: ' + Account + ' Password: ' + PW; // Second column
var subject = 'Google Account Request';
MailApp.sendEmail(emailAddress, subject, message);
}
This script is triggered on a new Form Submit. Attempting to pull the values from the last created row queried to a "Results" sheet, using lastRow to find the latest entries row, from select columns. Script runs without error, but no email is sent, telling me that it's not getting the values, or returning null values.
This is the sheet its pulling data from
You are only sending row 2 because you are retrieving only one value (Password.getValue() and AccountName.getValue()). Consider the difference between getValue versus getValues.
On the other hand, by declaring a range such as getRange("H2:H") ("Account Name") you are including every row in the spreadsheet, including rows with and without content.
How would I make it pull the values from the last created row?
There are two options:
getlastRow() (the "Sheet" versus "Range" version) "returns the position of the last row that has content" doc ref here. In fact, that item of documentation has a good example of how to declare a Range using the command.
there is another (very useful) utility described on StackOverflow that is a favourite of mine. This describes the number of contiguous rows, in a column, with content.
I suggest that you declare the range using getRange(row, column, numRows, numColumns).
"row" having been determined using one of the methods described above, "numRows"=1. Then getValues for that range will include only the values in that row, and your email will be sent only in relation to that row.
I've got checkboxes and selects where label is different to its value.
In the DB the value is saved ok, however, when viewing Form Entries (and pre-submit form data) for all the checkboxes and selects the values are displayed not labels. So I end up with not so informative IDs rather than names.
Is there a way to display labels instead of values in the Form Entries screen?
I came across your question while looking to do the same thing. I have a field called Account Type that stores the account type ID as the value. In the entries list I want to show the account type name, not the ID.
Here's the solution:
In your theme's functions.php file add the following filter:
add_filter( 'gform_entries_column_filter', 'modify_entry_view', 10, 5 );
You'll find the documentation for it here: https://docs.gravityforms.com/gform_entries_column_filter/
Then add the function code:
function modify_entry_view( $value, $form_id, $field_id, $entry, $query_string ){
//- Check the field ID to make sure you only change that one
if( $field_id == 14 ){
return 'modified value';
};
return $value;
}
In my case I'm using a custom field that I created called account_type that prepopulates a select menu with choices corresponding to each of the account types in our system. I used the following call to check the field type instead of checking based on field id since the id will change from form to form:
if( RGFormsModel::get_field( $form_id, $field_id )->type == 'account_type' ){
You could do the same thing but use the label property instead of type, like:
if( RGFormsModel::get_field( $form_id, $field_id )->label == 'Field Label' ){
In my case the value saved is a term id from a custom taxonomy I set up called account_type, so I simply use:
return get_term_by( 'id', $value, 'account_type' )->name;
to replace the account id with the account name.
FYI: The process is the same for the entry detail, use the filter documented here: https://docs.gravityforms.com/gform_entry_field_value/
I have a datagridview in my Windows form Application.
The datagridview has 3 column. First column is Combobox.
I am trying to add item to the Combo box but it is working.
Here is the code( Language C#)
foreach (int counter=0; counter<5; counter++ )
{
this.dataGridView1.Rows.Add();
DataGridViewComboBoxCell cbCell = new DataGridViewComboBoxCell();
cbCell.Items.Add("Male");
cbCell.Items.Add("Female");
dataGridView1.Rows[counter].Cells[0] = cbCell;
dataGridView1.Rows[counter].Cells[1].Value = firstname[counter];
dataGridView1.Rows[counter].Cells[2].Value = lastname[counter];
}
The grid is showing 5 rows. But first Combo box column is having no item in every combo box of those.
Please help.
Thanks.
Since the code does not show how the columns are constructed, it is difficult to tell what the problem could be, however the code is not using the DataGridViewComboBoxColum. The DataGridViewComboBoxColumn is all you need to make every row in column 0 a combo box with “Male”, “Female” choices.
The malformed foreach loop is incorrect and will not compile. I assume a for loop is what you were looking for. Following this for loop… a new row is correctly added to the grid. Then a new DataGridViewComboBoxCell is created and added the cell[0] of the current row. dataGridView1.Rows[counter].Cells[0] = cbCell;. This cell[0] is added to every new row.
This is unnecessary if the DataGridViewViewComboBoxColumn is set up properly. Adding the DataGridViewComboBoxCell is perfectly valid and basically allows you to put a combo box into any “SINGLE” cell. It works however, if used this way makes the use of the combo box itself questionable.
The loop is “adding” data to dataGridView1. As you are reading in the data, the part about “Gender” (male, female) appears to be missing so the value is not set as the other values are. Example: There is not a line like below:
dataGridView1.Rows[counter].Cells[0].Value = gender[counter];
If there was a “Gender” array that held this info, then when the code sets this value (Male, Female) in the line of code above the combo box column will automatically set the combo box selection to that value. The data will only be “one” (1) of the two values.
So assuming this is what you are looking for the code below demonstrates how to use the DataGridViewComboBoxColumn
A word of caution when reading data into a combo box cell; if the string data for the combo box column does NOT match one of the items in the combo boxes items list, the code will crash if not caught and addressed. If the value is an empty string then the combo box will set the selected value to empty.
// Sample data
string[] firstname = { "John", "Bob", "Cindy", "Mary", "Clyde" };
string[] lastname = { "Melon", "Carter", "Lawrence", "Garp", "Johnson" };
string[] gender = { "Male", "", "Female", "", "Male" };
// Create the combo box column for the datagridview
DataGridViewComboBoxColumn comboCol = new DataGridViewComboBoxColumn();
comboCol.Name = "Gender";
comboCol.HeaderText = "Gender";
comboCol.Items.Add("Male");
comboCol.Items.Add("Female");
// add the combo box column and other columns to the datagridview
dataGridView1.Columns.Add(comboCol);
dataGridView1.Columns.Add("FirstName", "First Name");
dataGridView1.Columns.Add("LastName", "Last Name");
// read in the sample data
for (int counter = 0; counter < 5; counter++ )
{
dataGridView1.Rows.Add(gender[counter], firstname[counter], lastname[counter]);
}
Hope this helps.
code:
class Users(db.Document, UserMixin):
first_name = db.StringField()
last_name = db.StringField()
username = db.StringField(unique=True)
password = db.StringField()
email = db.StringField()
following = db.ListField(db.StringField(), default=[])
role = db.ListField(db.StringField(), default=["user"])
confirmed = db.BooleanField(default=False)
confirmed_on = db.DateTimeField()
so if I wanted to remove a certain string from the Users.following field
Users.objects(username="some_user").update(pull__following=["some_string"])
and then save it?
because I've tried this and it won't remove the string from the following listField
If you want to remove one element from your list you need to use the pull modifier which takes a single value not a list as you are doing so the correct query is:
Users.objects(username='some_user').update(pull__following='some_string')
You can also remove several element from your "following" list using the pull_all modifier; and in this case you pass in a list of value.
Users.objects(username='some_user').update(pull_all__following=['one_string', 'another_string'])
I have created a custom module with Module Creator (v 1.7).
Have one multi-select admin form field.
As the multiselect field on submitting gives array , the same value (i.e Array) is stored in database.
To avoid this on saving the submitted value , I just manipulated the code by storing it in e.g a,b,c form.
Through this the data is saved successfully.
Now in grid , I want to filter it , as we have for Status part [1=>Enabled 2=>Disabled].
please suggest How would I achieve this .
Take a look at magento filter_condition_callback option
$this->addColumn('categories', array(
....
'filter_condition_callback' => array($this, '_applyMyFilter'),
..
)
);
protected function _filterCategoriesCondition($collection, $column)
{
if (!$value = $column->getFilter()->getValue()) {
return;
}
$this->getCollection()->addFieldToFilter('categories', array('finset' => $value));
}
See
Filtering a text-type column with MySQL-computed values in Magento Admin Grid
Magento: How to search or filter by multiselect attribute in admin grid?