Powerapps: Patch a record based on a text input control - patch

I am wrestling with a simple patch function to update a record based off the value of an text input control. What I want is for PowerApps to update a record where a value in a table = the value in a text input field.
Table2 contains my data.
ID is unique for each row.
ProjID is the name of the text input control. This contains the value of ID that I want to update.
Current Phase is the column I want to update with the value in projID.
I have based the code below off some code which I use to create new records which works, so I think it is the lookup element that is not working.
Patch(
Table2,
lookup(Table2,Id = ProjID.Text ),
{
'Current Phase': CurrentPhase.Text,
}
)
)
Any help would be greatly appreciated!

The below should work and you can use comma either to add more conditions or data values
Patch( Table2,
First(Filter(Table2, ProjID.Text = Id ) )
, {
'Current Phase': CurrentPhase.Text
}
)

Related

How to delete DDIC table records which have different id than row number in internal table?

I have an ALV with two rows. I want to delete these rows in internal table and dictionary table also. To get which rows in alv i chose, i use a method
go_selections = go_salv->get_selections( ).
go_rows = go_selections->get_selected_rows( )
Nextly, i am iterating through results LOOP AT go_rows INTO gv_row.
Inside above loop I have an another loop, which stores data from internal table into workarea. Then, i set the counter variable which holds the id of the dictionary table and delete respective row.
LOOP AT gr_data INTO lr_znewfdkey6.
counter2 = lr_znewfdkey6-id.
IF counter2 EQ gv_row.
DELETE FROM znew_fdkey01 WHERE id EQ lr_znewfdkey6-id.
MESSAGE 'Row deleted .' TYPE 'I'.
But unfortunately this works only when id of the dictionary table is equal to row number selected in alv. If I have lr_znewfdkey6-id in dictionary table, equal to for example 5, get_selected_rows( ) returns value started by one etc., and this will cause inequality.
How to fix this?
Get selected rows returns a table of line numbers.
lt_rows = lo_selections->get_selected_rows( ).
Those numbers correspond directly to the itab you loaded into the ALV. No matter if it has been sorted or filtered. It does not correspond to any fields in the database like an ID field or anything.
Assuming gr_datais the itab assigned to the ALV. Let's loop lt_rows and read gr_data at index
LOOP AT lt_rows ASSIGNING FIELD-SYMBOL(<row>).
READ TABLE gr_data INTO ls_data INDEX <row>.
IF sy-subrc = 0.
APPEND ls_data TO lt_selected.
ENDIF.
ENDLOOP.
After executing this will collect selected gr_data lines into lt_selected itab. To delete
LOOP AT lt_selected ASSIGNING FIELD-SYMBOL(<row>).
DELETE TABLE gr_data FROM <row>.
ENDLOOP.
You could also simply do:
LOOP AT lt_rows ASSIGNING FIELD-SYMBOL(<row>).
DELETE gr_data INDEX <row>.
ENDLOOP.
After that refresh your ALV. Should be good.

SQL*Loader: Use a field not in the table

Got an odd question, I'm trying to load some data into Oracle using SQL*loader.
The trick is, there is a field provided which I need to use as input to a user function to calculate another field. The original field I don't want to load.
I tried this: however, a FILLER field cannot be referenced as a BIND variable:
LOAD DATA
APPEND
INTO TABLE my_table
(
XREF_NUM FILLER POSITION(8:26),
ID_NUM POSITION(1:1) "my_func(:XREF_NUM)",
... other columns ...
)
Table defintion is just:
ID_NUM
COL1
COl2
but XREF_NUM does not exist in the table.
How do I set this up ?
Define it as BOUNDFILLER, which means treat it as a "remembered" FILLER. You can use it in expressions.
LOAD DATA
APPEND
INTO TABLE my_table
(
XREF_NUM BOUNDFILLER POSITION(8:26),
ID_NUM POSITION(1:1) "my_func(:XREF_NUM)",
... other columns ...
)

Edit the code of a GridView column asp.net

I've been looking for a way to control the text that appears in a particular column of a GridView.
For example consider a database with two tables Student and Class.
I want to add a column to the GridView which print out all the students in the Database, the column will show the student's class name, how can do it? (I can normally print the ClassId since its a FK in the student table)
I want to add a column to the GridView which print all the classes, the column will count the number of students in each class, how can I do it?
1- You can do that simply with inner join or a stored procedure to get the class name beside all the data you need in your query.
2- More than one way to do what you want:
For example:
you can add a column to your data table (empty column ), and fill it later through using Sum() aggregate function in a query.
DataTable result_dt = DAL_Helper.Return_DataTable(sqlSelect);//your original query
result_dt.Columns.Add("NumberOfStudent");
result_dt.Columns["NumberOfStudent"].DataType = typeof(string);
result_dt.Columns["NumberOfStudent"].MaxLength = 255;
if (result_dt.Rows.Count > 0)
{
for (int i = 0; i < result_dt.Rows.Count; i++)
{
//Here u can fill your new empty column.
}
}
result_dt.AcceptChanges();
After you return your customized data table(as a data source), you can bind it to the grid view.
Another solution : add an empty column to the grid view and in the RowDataBound event of the grid view you can fill this column through some loop and you can use LINQ to help you in getting the summation.

Drupal CCK field select option names, where are they?

I have a custom content type which has a field called "location" which is a long select list (100 or so items). I want to get an array of all locations which have a piece of content associated with them. The numeric value of this field is stored in content_type_[my_content_type], but I can't find anywhere in the database where the name of the values are stored. I hope that's not too confusing - just to be clear, I want to do something like this:
SELECT DISTINCT(field_location_value) FROM content_type_[my_content_type]
and then
SELECT field_location_name_or_something FROM where_on_earth_are_the_names_stored
and then do something with the two arrays to find the names I want.
Can anyone help?
Thanks a lot. Drupal 6, by the way.
If you mean select list field of CCK:
Get all location associated with current node (piece of content?):
$node = node_load('YOUR content ID');
print_r($node->field_location); // $node->field_location - this will array of values.
Get all values of that field (defined in "Allowed values"):
$content_field = content_fields('field_location');
$allowed_values = content_allowed_values($content_field); // array of values
I found this, after much trial and tribulation, in the database table content_node_field_instance, under the field's widget settings field.
This Drupal 6 code snipped will retrieve your cck field value options and put them in the $allowed_values variable as an array. Replace 'YOUR_CCK_FIELD_NAME' with your cck field name (name, not label)
$cck_field_name = 'YOUR_CCK_FIELD_NAME';
$cck_field = db_fetch_object(db_query("SELECT global_settings FROM {content_node_field} WHERE field_name = '%s'", $cck_field_name));
$cck_field_global_settings = unserialize($cck_field->global_settings);
$allowed_values = explode("\r\n", trim($cck_field_global_settings['allowed_values'], "\r\n"));
In Drupal 7 if you have a field of type List (text) then I have written the following function to return an array of options:
function get_drupal_select_options($field_name) {
$options = unserialize(db_query("SELECT c.data
FROM field_config_instance i
INNER JOIN field_config c ON c.id = i.field_id
WHERE i.field_name = :fieldname", array(':fieldname'=>$field_name))->fetchField());
return $options['settings']['allowed_values'];
}

Column Value of multiselect rows in jqgrid

Its like I have multiselect option in Jqgrid in which i want to pass the selected rows value to the server and based on the value i will delete the rows. I dont want to have the ids to do my work. For the Single row i get the cell value and delete using the same. But for multi select its not the case. In getGridParam('selarrrow'); I use this to fetch the selected rows bu the values are not getting populated. Please help me out in doing the same
When i use the following code as i saw in some sample question i can fetch the value for the single row selection but when i select multiple rows then i pass it says like "FALSE" or "UNDEFINED". What can be the issue. var grid = jQuery('#list'); var sel_id = grid.jqGrid('getGridParam', 'selarrrow'); var myCellData = grid.jqGrid('getCell', sel_id, 'CountryId');
I got this done by using the for loop for getting the selected rows id
i did some thing like this and I am able to fetch the value. Thought this might help others too please check it
var myrow;
var id = jQuery("#List").jqGrid('getGridParam','selarrrow');
if(id.length)
{
for (var i=0;i<id.length;i++) // For Multiple Delete of row
{
myrow = jQuery("#List").jqGrid('getCell',id[i],'ticker');
}
}

Resources