getting label value from form - asp.net-mvc

i have a form created with some textboxes and dropdown lists, they are updated dinamically using jquery, some of the values that i update, i push them in some labels, because i don't want that the user modify them. i need those values but i don't know how to take them and push into an object that i created.
i don't know if i made myself clear. this is and example of my code
Pedidos miDetalle = new Pedidos(); //<= object
miDetalle.codTipoArt = Request.Form["ddTipoArticulo"]; // <= value from dropdown list
miDetalle.clave1 = Request.Form["tbClave1"]; // <= value from textbox
miDetalle.nombreArticulo = Request["#lbNombreTela"]; // <= how i'm trying to get the value

Inside your controller action you could get only values that were part of the POST. And only values of input fields will be sent to the server. So you could use hidden fields to store those values on the client. You cannot store those values in some labels and expect those values to be sent to the server when the form is submitted. So using jQuery instead of setting the values in labels you need to put them in addition in hidden fields with specific names and on the server you will be able to fetch those values using Request["MyHiddenFieldName"] or even better using a view model.

Related

Antd. Form.List and Form.Item get data from initialValue

Can you please tell me how can I pass data from initialValue (line #187) to (line #217)?
I need to do a check, and for this, I need to get the index of the current object I'm accessing and the main data set (that is, initialValue).
I used this example - https://ant.design/components/form/#components-form-demo-dynamic-form-items-complex
The problem is that I don't know how to get the original dataset from the .
The idea is this: The user can change the name/description of the fields only for the newly created objects that they added through the button (as in the example), but for those fields that were immediately created from the data set - they cannot, that is, they have should be on.
Tell me, please, how can I do this?
I haven't been able to solve the problem for over an hour now.
I need to somehow assign a custom ID (from a dataset) for each form.
And then pass the information of this field to the validator. If it has id != null => the field becomes disabled.
But damn, how to do it.... 🙁

Archer to Archer Data Feed in RSA Archer

Need to create Archer to Archer Data Feed that should set value of two fields as NULL in a cross referenced application, if the value of a field is Approved in first field. I am not getting how can I send a NULL value to the fields through data feed??
Archer doesn't have "NULL" value, but you still can get it done like this:
Step 1. Calculation. Open your data feed configuration and go to the source definition tab. Add a new field to the end of the list and make it calculated.Add formula to check value of 1st field that present in the data source and if it is equal to "Approved" then return empty string.
Something like this
=IF([field field] = VALUEOF([first field],[Approved]), "","SOMETHING ELSE")
The key here is to have this calculation return an empty string when you need it - "".
I suggest you to test your calculation in the calculated field in the application before you put it in the calculated data source field.
Step 2. Data feed mapping. Now you need to map new calculated field in your data feed to the field you want to remove value from. Go to the mapping tab in your data feed configuration and map the field. Make sure to selection options "Replace value" and "Empty Values" - this way existing value will be replaced even with empty values.
Similar approach works for me in multiple data feeds.
Good luck!
You can use novalue() function in the calculation
I don't believe there is a concept of NULL in Archer. The closest you're probably going to get is blank/empty. To do that, in the Data Map tab of your data feed, click the edit icon under Actions column. Check the box that Empty Values should be populated rather than ignored.
Assumption is that what is in the question is the only task required by the data feed.
Create report with the filter set as First Field = Approved
Fields to display should contain tracking id (tracking ID which is configured to System ID) of the Target app along with the Tracking ID of the Cross-Reference App.
In Source Definition add new source and give it an adequate name as clear or Null if you want
Where it says Raw Data Field in the drop-down, update this to static. Leave the source as not configured or unconfigured.
Map this newsource to the 2 fields that you are trying to clear. In Options set to Replace and uncheck add unknown and set to populate empty values.
Map the Tracking ID of the Target app and map the Tracking ID of the cross-reference.
Set key field definition for both apps to the tracking id
Set data feed to update only. Remove checkmark for create
If your are doing more than just clearing the 2 fields, then
Stan Utevski answer is mostly correct except you must have the field you are evaluating for "Approve" in the fields to display of your report. Otherwise the calculation will not validate.

Dynamically update instance variable

I would like to make an API call dynamically. API (Get) result must vary dynamically based on the query string passed.
I have hard coded the API URL without any query string, and supplied the API URL as an instance variable:
#apiRequest = HTTParty.get("http://localhost:1880/api/devices")
#parseApiRequest = JSON.parse(#apiRequest.body)
I want #apiRequest to change dynamically based on user input from a form (I had already developed a form that gets inputs from user's).
Is it possible to change the value of an instance variable dynamically? User's input value must be passed onto that controller as a query string.
Sample image that gets user input:
Getting User Input
The instance variable must be updated dynamically as,
#apiRequest = HTTParty.get("http://localhost:1880/api/devices?device_id=123456")
Kindly suggest.
Simply interpolate the dynamic data into the api request parameter string:
extraParamsOrPath = "assemble this from form inputs"
urlPrefix = "http://localhost:1880/"
#apiRequest = HTTParty.get("#{urlPrefix}/#{extraParamsOrPath}")
And make sure the user input is sanitized ;)

Scout Eclipse Neon set title of the field label in form data

I am wondering if you could set title of field in form data on server side.
Use case for this is that you have one field, and depend on some server logic you would set title of the field. Is it posible to set it on server somehow, to not sending string value to client and then set the title.
I was looking at method
formData.getMyField.setPropertyByClass(c, v);
but I don't know if this method could do this and which property I need to set.
FormData classes can contain two types of data holder classes:
data holders for values associated with value fields (these holders always extend AbstractValueFieldData) and
data holders for values associated with form data properties (these holders always extend AbstractPropertyData).
A form data property is generated if the associated form has a member variable whose setter and getter is annotated with #FormData.
The method setPropertyByClass(...) is intended to set the value of a form data property in a form data object.
The method cannot be used to set the label of a form.
The standard way to set the label of a field would be to load the form data from the server and to set the label afterwards, as in the following code snippet:
...
public class ModifyHandler extends AbstractFormHandler {
MyFormData formData = SERVICES.getService(IMyProcessService.class).load();
importFormData(formData);
getMyField.setLabel(formData.getMyProperty().getValue());
}
...

Get the display value from a DropDown

I'm trying to access the values in the FormCollection inside of an action. I can get the value field by doing:
var value = formCollection["MyDropDownList"];
But I can't seem to find a way to get the display value. Am I missing something obvious? A cast perhaps?
Getting text from an HTML drop down selection list using JavaScript code
To get the text from each option is slightly trickier. We use the selectedIndex property of the selection list to capture the selected option and then pass this value to the options[].text property.
Here is the code
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
I don't think there's a way to get the display column from the formcollection. Basically, the formcollection is an easy way to interrogate the Request object (Request.Form, Request.QueryString, etc.) and the only thing that goes into that are values from input fields.
If you really need to get the display text, you would have to get it from whatever collection you bound the list with and access it via the key (your selected value from the formcollection). For example, if it's a dictionary collection that you bound to the list, use that same dictionary to lookup the value based on the key.
I would need to know more information as to how you're binding the dropdown to help you further.
That's the normal behaviour. When a form is posted, only the name-value collection generated from the form fields are sent to the server. And of course the inner text of the option tag doesn't belong to that collection.
you do it ok, dropdown list sended shows value of selected item not displayed text of selected item...if you want(from some reason, because I am asumming you are filling that dropdown on model right? :)) to see send a display text also, maybe you can put it in hidden field with javascript on every change of selection in dropdown...
cheers

Resources