I have a data bound field say "Role"
The values in the database for its corresponding field contains 1,2,3.
I need to know whether i can format that databound field according to the value
for eg:
if 1 is the value, it should show "Admin".
if 2 is the value, it should show "Support".
if 3 is the value, it should show "User".
can i use DataFormatString for this purpose??
PLS HELP.
One approach is get this value before you display it e.g from database or codebehind
Select
Role,
CASE
WHEN Role = 1 THEN 'Admin'
WHEN Role = 2 THEN 'Support'
WHEN Role = 3 THEN 'User'
END RoleDescription
FROM MyTable
Output is below. You can use the RoleDescription value instead of Role
Role RoleDescription
----------------------------------
1 Admin
2 Support
1 Admin
1 Admin
3 User
Atlast i found a WAY.. anyways thanks codingbiz!!
Make that field as a templatefield and edit that template. In the item template view, remove the label field and insert a dropdown. there you manually add the items with its values and bind selected value to the field (here role).
steps..
Select item > convert it to TemplateField >
Edit template > select that template (ItemTemplate) >
Change label to dropdown > add items to drop down with its value > bind selected value property to the original data field..
THATZ IT!!
Related
In Notes I have a form (Order) in which I have button "Create new OrderLine" which creates a new form(Orderline). The Order document has an embedded view on the design which gets orderlines documents. Each orderline document contains a hidden field with the ID of the order document, so that you know which orderline is connected with which order. Same goes for Orderline this has an embeddedview with Prices.
In the Order form I have 2 editable text fields: AdministrationNumber and DebtorNumber.
In the OrderlineForm I only got the debtorNumber
In Prices I have a editable number field called Fee.
So I did this on various ways:
In the postOpen of the form prices I have put this LotusScript code:
If( (Source.FieldGetText( "AdministrationNumber" ) = "1" ) And (Source.FieldGetText( "DebtorNumber" ) = "2") ) Then
Call Source.FieldSetText("FeePercentage", "4.235")
Call Source.Refresh()
End If
But did not work.
In Default Value of Fee I also tried this formula code:
#If((AdministrationNumber="1") & (DebtorNumber= "2");
"4,235";
"0"
)
But also of no use..
Is it possible for an editable field to be set when opening the subform based on conditional statement with data which is in the parent form?
Edit
2 ways to solve:
1.
When clicking "Add new Orderline" Button whic is on the Order form, I will call a function in the scriptlibrary, in this function I get values of debnr and admnr and then do the conditional statement.. If true then set FeePercentage
2.
Added new hidden field on the orderlline called admnr which gets the administratorNr field data when the New Orderline Button is clicked.. The field is set through a function in the scriptlibrary.
Eventually in the postOpen of the prices subform this works:
Dim doc As NotesDocument
Set doc = Source.Document
If doc.admnra(0) = "1" And doc.debnr(0) = "2" Then
doc.FeePercentage = 4.235
End If
Work with back-end classes instead:
Dim doc as NotesDocument
Set doc = Source.Document
If doc.AdministrationNumber(0) = "1" And doc.DebtorNumber(0) = "2" Then
doc.FeePercentage = 4.235
End If
It gives you easy access to all fields in document.
You say "subform" which has a special meaning in Notes design but it sounds like what you have is a form called "Order", a form called "OrderLine" and a subform called "Prices" that the OrderLine form uses?
In which case, make sure the OrderLine's the "Formulas inherit values from selected document" form property is checked.
That and your default formula should do it if the button is on the parent form (as opposed to view the Order form embeds).
P.S. You might want to change your default formula to
#If(
(AdministrationNumber="1") & (DebtorNumber= "2"); 4235;
0
)
so that it returns a number instead of text that looks like a number.
In the form cutslistepage , i want to get the value of accountNum of the selected row in grid and passe it to another form
i have try that :
int64 recordsCount;
recordsCount = CustTable_ds.recordsMarked().lastIndex();
// CustTable = CustTable_ds.getFirst(1);
If you want to retrieve the CustTable record, check the CustTableListPageInteraction class.
In the selectionChanged method, it has the following code:
custTable = CustTable::findRecId(this.listPage().activeRecord(queryDataSourceStr(CustTableListPage, CustTable)).RecId);
This is how you can retrieve the record. But since it is already done, you can simply use the custTable variable that is already declared in the class declaration.
Side note: if you have an other form that is opened from the list page, it should automatically be filtered based on the relations between the data sources of the form. So you might be searching for a solution for a problem you shouldn't have. For example create a form that has a data source with a relation to the CustTable table on it and it should create a dynaink between the list page and your form, filtering the records for that customer.
If only one record is selected you can do:
info(CustTable_ds.accountNum);
Otherwise, if more than one record is selected you need to do something like:
custTable = CustTable_ds.getFirst(true);
while (custTable)
{
info(custTable.accountNum);
custTable = CustTable_ds.getNext();
}
Foreign key fields in Dynamic Data show the next char field of the child table in dropdownlist. How can I tell it to show another field?
Assume these tables:
Personnel(PKPersonnelID, PersonnelName, FKDepartmentID)
Department(PKDepartmentID, Description, Department)
FKDepartmentID in Personnel table is a foreign key to Department table. When I want to insert new record to Personnel, Dynamic Data shows me a DropDownList for FKDepartmentID. In this DropDownList the values from Description field are displayed(As I recognized it shows the first char field after the primary key). But I want to show Department field values.
The code where you are binding the data with the drop down list, can you please show it over here, let say your drop down list Id is drpDepartment, than make your binding like:
drpDepartment.DataTextField = "Department";
drpDepartment.DataValueField = "PKDepartmentID";
drpDepartment.DataSource = YOURCOLLECTION OR DATASOURCE;
drpDepartment.DataBind();
I have DDL in custom control that in the default case I insert new item with certain value.
but in a certain case I insert another item and want to the previous item to be deleted.
I tried to remove the first item and insert the another
I tried to change text and value of the inserted item
the 2 ways failed because:
in the first load of page, it take the value of the first item and text of the second,
then if I select another thing from DDL and then return to my Item, it take its correct value.
I need the second to take the correct value in the first load of the page.
Im not sure what you mean exactly,but let me try to help.
Page Load, the DDL has Item 1 loaded e.g. ItemText:Stack ItemValue:Overflow
Then on some action the above is deleted and a new Item is Inserted?
If so, could you try somthing like,
VB
With me.DDL
'Remove all Items from the DDL
.Items.Clear()
'Insert New Items
.Items.Insert(0, New ListItem("VALUE",TEXT"))
End With
C#
//Remove all Items from the DDL
this.DDL.Items.Clear();
//Insert New Items
this.DDL.Items.Insert(0, new ListItem("VALUE", "TEXT"));
Each table in the AOT has an ID, how can I discover the table name given an ID?
Looking at the SQL dictironary is really the correct method.
Search for the line with the FieldId equal to 0.
Using TSQL this will tell the name of the table for tableid 505
select NAME
from SQLDICTIONARY
where TABLEID = 505
and FIELDID = 0
From X++, use the tableId2Name function.
From the GUI, choose Tools/Development tools/Application objects/Application objects and filter for a recordType of TableInternalHeader and a parentId of the table id you are looking for.
Or in the AOT, right click on Tables and choose Find. On the Name & Location tab, set Search to All nodes. On the Properties tab click Selected next to ID and fill in the table id in the Range field.
I dont'know if this is your answer,
if you want to give the TableName with his ID, you can use
the method:
str tableId2Name(int _tableid)
For example:
If YourTable has ID :123456 ;
use method
tableId2PName(123456)
will return the str name YourTable.
info(strFmt("%1" , tableId2PName(123456))); -> VideoStamp the name.
I used the info in
https://msdn.microsoft.com/en-us/library/aa498759.aspx
I hope to useful , greetings!
If you need AX system table name you can use tableId2name or DictTable.name method.
If you need SQL table name you shoud use DictTable.name method with first argument of DbBackend::Sql
Example:
print new DictTable(tableNum(DirPartyTable)).name(DbBackend::Sql);
print new DictTable(tableNum(OMOperatingUnit)).name(DbBackend::Sql);
pause;
// result:
// DIRPARTYTABLE
// DIRPARTYTABLE
Or you can try:
select Name, AxId
from MicrosoftDynamicsAX_model.dbo.ModelElement (nolock)
where ElementType = 44
order by AxId
In the AOT, go to the System Documentation node.
In the Tables node, find SqlDictionary and open it with the table browser.
Filter the column TabId with your ID.
In the AOT, go to the System Documentation node. In the Tables node, find SqlDictionary and right click and open it with the table browser. Filter the column TabId with your ID and fieldid == 0, his will give you the name of the table.
Easiest way:
Create a project (not necessary but easier to delete later)
Add a new view to your project
Add the data source SqlSyncInfo
Drag the fields ID, MessageType, SyncTable, TableName, etc to field
Open the view
It provides all the table names and their respective IDs. Just filter what you want. If you know the table ID, search for that. If you know the table name, search for that.