How to create a display,or similar, method with paramater? - forms

in my myForm I call in a tableMY a displayMethod_fieldA.
In myForm I insered a some date in a DateEdit and I want to make a selection in table using the entered value. If I crete a displayMethod whit parameter I have an error.
Look like this code I get error:
display myEDTField displayMethod_fieldA (date _dateFromForm)
{
tableMY table;
select table
where table.item == this.item
&& table.dateTable == _dateFromForm;
return table.valueFieldA;
}
I have an error looklike this:
The display method has an incorrect parameter profile.
There is another way to display or set the value in my StrinEdit in Grid by method passing a parameter?
In web I saw the method modifier modifierMothod , but I need some more explanation. I don't know if this method is a right way.

Display methods are not designed with this feature.
display method for a table, form, report, or report design does not
have any parameters. For example: display Amount amount()
A display method for a form data source does require a parameter. You
use the
parameter to specify a table buffer. The type of the table buffer has
to match the type of the table in the form data source.
https://msdn.microsoft.com/en-us/library/aa595058.aspx
You can create the desired behaviour with an edit method (and setting the field to AllowEdit(false) or enabled(false).

Related

How to retrieve the rows which are selected in the list report page of smart templates

This is the List Report type of Smart Template application
Here I have selected 2nd and 5th row, I also have a button named Send Requests in the section part which is highlighted. If I click this button it calls a javascript controller function which is defined in the extensions of the application. In this js function how can I retrieve the selected rows that are selected?
I have enabled the checkboxes in this page by mentioning this code
"settings": { "gridTable": false, "multiSelect": true } in the manifest.json
As it was recommended by this link https://sapui5.netweaver.ondemand.com/#docs/guide/116b5d82e8c545e2a56e1b51b8b0a9bd.html
I want to know how can I retrieve the rows which got selected?
There is an API that you can use for your use case. It is described here: https://sapui5.netweaver.ondemand.com/#docs/guide/bd2994b69ef542998becbc69ab093f7e.html
Basically, you just need to call the getSelectedContexts method. Unfortunately you will not be able to really get the items themselves, only the binding contexts (which point to the data entities which are selected). Excerpt from the documentation:
After you have defined a view extension, you can access and modify the
properties of all UI elements defined within these extensions (for
example, change the visibility). However, you cannot access any UI
elements that are not defined within your view extensions.
In this type of table there is way.
var myTable=sap.ui.getCore().byId("your table id");
get all rows:
var myTableRows=myTable.getRows();
now get selected Indices
var selectedIndeices=myTable.getSelectedIndices(); //this will give you array of indeices.
now run loop on indeices array. And get particular row item;
// get binding path
var bindingpath=myTableRows[2].getBindingContext().sPath; // this will return eg:"/ProductCollection/2"
// now get Binding object of that particular row.
var myData=myTableRows[2].getModel().getObject(bindingpath); // this will return binding object at that perticular row.
// once your loop is over in the end you will have all object of selected row. then do whatever you want to do.
If you use smart template create an extension.
This is the standard event befor the table is rebinding:
onBeforeRebindTableExtension: function (oEvent) {
this._table = oEvent.getSource().getTable();
}
In your action function (or where you want) call the table and get the context :
this._table.getSelectedContexts();

return multiple columns from stored procedure in MVC

Was previously using this line in my controler to return an id and text column from, a stored procedfure in asp.net MVC
user = new SelectList(ctx.Database.SqlQuery<LkUpGenderModel>("EXEC dbo.uspGetLkUpGender").ToList(), "GenderID", "Gender");
However i now want to return more text values, I have extended the model to have these extra fields but I'm getting an error.
Is there a way to get this working:
user = new SelectList(ctx.Database.SqlQuery<LkUpGenderModel>("EXEC dbo.uspGetLkUpGender").ToList(), "GenderID", "Gender", "GenderShort", "GenderCombined");
currently it flags the SelectList( saying the call is ambiguous
The previous code simply returns instances of LkUpGenderModel and then builds a SelectList from that using the GenderID property of that class as the value and the Gender property as the display text.
Your new code doesn't request more properties, it simply passes additional parameters to the SelectList constructor: namely, dataGroupField which you're setting to the GenderShort property, and selectedValue, which you're setting to the GenderCombined property. See: https://msdn.microsoft.com/en-us/library/dn725507(v=vs.118).aspx.
If you have additional columns being returned from the stored procedure that you want filled in on the class, then you should add additional properties to the class to handle those. However, since all you're doing with the data is creating a SelectList from it, you can't send any additional data to the view other than the value and display text, making returning additional data pointless in this instance.

Ligthswitch 2013 Set value ACB when launching from another screen

I have a search screen called TimesheetsByjob. This is based on a query called TSByJob and has one parameter called JobID. Normally the user will just open this screen and select a job. The ACB's JobID field is bound to the query parameter JobID.
I now want to add a button in the timesheet entry form to open this search screen from a button. Obviously, I know what the JobID is, so I want to (and the user will expect me to) preset the JobID instead of them having to select it from the ACB.
In the timesheet entry form my button as this is the Execute code:
int JobID = TimesheetProperty.Job.ID;
Application.Current.ShowSearchTSByJob();
I want to pass a param, but the method doesn't expect one.
Is there a way to overload the method to accept a param (if so where would I do that), or is there another way to do it other than making a 100% duplicate of the search screen and using a local property?
Regards
mark
In your SearchTSByJob screen, add a local property of the type you require. In that local property's Properties, check "Is Parameter".
Now you can pass a parameter to that screen. If you have multiple, Intellisense will tell you the order it expects.
int JobID = TimesheetProperty.Job.ID;
Application.Current.ShowSearchTSByJob(JobID);

Adding a form filter

I'm currently working on a form in Microsoft Dynamics AX.
The form consists of a grid with about 10 fields from 4 different tables.
As the form is now it returns too many values so I need to include some sort of filter, it doesn't need to be dynamic, just a static filter saying only show the lines with value X in column Y.
Has anyone here got some experience with this sort of thing? Where do I start?
I must say I'm not experienced with Microsof AX at all, I've been working with it for about a month now.
I've tried to follow this guide: How to: Add Filter Controls to a Simple List Form [AX 2012]
But I got stuck at the second part (To add a control to the custom filter group) Step 2: I dont know which type of control to chose, and ik i pick lets say a ComboBox i cant get Step 3 to work because I dont see the 'Override Methods' they mention.
Well, I usually do it this way:
In ClassDeclaration, create as many QueryBuildRanges variables as fields to filter. Let's name them Criteria1, Criteria2, etc (name them properly, please, not as here)
QueryBuildRange criteria1, criteria2;
In each Datasource you need to filter, override method Init, an add code similar to this:
super();
criteria1 = this.query().datasource(tablenum(tableofdatasource)).addQueryRange(fieldNum(fieldtofilter))
//criteria1.status(RangeStatus::locked); //optional - this way you can hide filter field to user, have it readonly for users, etc
Create a control of type StringEdit or ListBox in form to be used as filter. Change their AutoDeclaration property to Yes. Override modified() method. In it, I use to put something similar to:
super();
element.changeFilters();
In form, add method changeFilters();
range rangeFromStringControl = StringEditControlName.text(); //Put in rangeFromStringControl the string to be used as filter, as a user would write it
range rangeFromListBoxControl;
criteria1.value(rangeFromStringControl);
switch (listBoxControl.Selection())
{
case NoYesAll::All:
rangeFromListBoxControl = ''; //Empty filter string - No filter at all
break;
case NoYesAll::No:
rangeFromListBoxControl = QueryValue(NoYes::No); //Or whatever string filter value you want
break;
//Etc
}
//We have all filter strs done; let's filter for each main DataSource required with new filters
DataSource1.executeQuery();
//If there is other datasources joined to this one, it's usually no necessary to call their executeQuery;
//If there are others with filters and not joined to it, call their executeQuery()
If you need this filter to be applied when form is open, set appropiate initial values to controls, and then in form's run() method:
run();
element.changeFilters();

Axapta: Edit form field values

Using a 'clicked' override on a button, I'd like to modify values in an Axapta form.
I'm able to get data from the form field using:
str strOld = Form_FieldName.valueStr();
I'm able to prepend text to the field using:
Form_FieldName.pasteText(strNew);
I can't seem to find a .clear method or .value= method. I'd like to replace the entire value in the field with new information.
Thanks
If the field is bound to a datasource, you have to modify the value in the datasource. If the field is bound to a variable, then modify the value of the variable itself. It is the easy an smart way to do it.
You can modify the value in the form control by using the .text() method. (The control have to be the AutoDeclaration property set to Yes). This is a setter-getter (parameter) type method used in AX. If no parameter is passed, it is user as getter (read). If you pass a value, this is a setter (write).
Hope this helps.