Options

C/SIDE Tips&Tricks

mfabianmfabian Member Posts: 187
edited 2000-07-27 in Navision Financials
Hi everybody,
In march this year, Navision Switzerland started a little competition amongst Fin developers about the most usefull C/SIDE tricks.
The result is nothing which would make an experienced Navision programmer jump out of the chair but nevertheless some of the tips might be useful, especially for newbies:

--- Cut&Paste in Source Expression ---
As you know, you can open the a List of C/AL Expressions with F5 on the SourceExpression Property. Unfortunately you cannot insert a variable directly in the SourceExpression by selecting a variable and pressing <Enter>.
However you can Copy the variable with Ctrl-C in the List and paste it with Ctrl-V in the SourceExpression property.
Better than nothing.

--- Options ---
Let's assume you defined a Field Layout: Option (Adress,Telephone,Statistics,Budget).
In C/SIDE code you would access an option as e.g. Layout::Telephone
Now, many days have passed, many bears have been drunk and you forgot the spelling of the options. What to do?
Program (wrong by purpose) "Layout::x" and compile. The compiler now lists all possible options.
You can also write "Layout::T" which the compiler will replace correctly with "Layout::Telephone" as there is only ONE option starting with 'T'.

--- Insert Fields into Dataport ---
In a Dataport, on the Field Designer, open the field menu. Select the fields you want to add to your dataport from the field menu then click somewhere into the field designer window and the selected fields will be added.

--- Debugger: Find line which causes error ---
If you have an error in your program, you need to find the program line which causes the error.
From the Debugger menu active the option "Active" and DEACTIVATE the option "Breakpoint on Triggers".
Then run your errournous code again and the debugger will stop at the line which causes you sleepless nights.

--- Dataport Requestform ---
By default, Dataports let you select the Import/Export filename. However, as soon as you use the RequestForm this Filename-Field disappears.
If you want both, RequestForm and Filename do the following:
1) Define a global Variable "Test"
2) Insert a Textbox with SourceExpression "Test"
3) Set the AsistEdit property to "yes"
4) Assign ControlID "1" (one) to the Textbox! It only works with ID 1.
5) OnAssistEdit Trigger of Textbox insert the code:
Currdataport.Filename := test;

--- Report: Print Options from Request Form ---
On the Request Form you define variables like layout, number of copies, etc. Now you want to print these options.
Simply Copy/Past the fields from the RequestForm to the sections. It is also possible to copy/paste normal fields and even buttons from forms into the report sections.

--- Input Dialog ---
You need the user enters some parameters but you don't want to create a form for it:
Let's ask for three dates within our codeunit:
Var
window : Dialog;
BookingDate : Date;
DocumentDate : Date;
DeliveryDate : Date;
EntryNo : Integer;
NewEntryNo : Integer;

Window.open ('Booking Date #1#########\'+
'Dok. Date #2#########\'+
'Shipment Date #3#########',
BookingDate,DocumentDate,DeliveryDate);

EntryNo := 0;
NewEntryNo := 1;
While (NewEntryNo > 0) and (EntryNo <> NewEntryNo) do begin
EntryNo := NewEntryNo;
Case EntryNo of
1 : NewEntryNo := Window.input(1,BookingDate);
2 : NewEntryNo := Window.input(2,DocimentDate);
3 : NewEntryNo := Window.input(3,DeliveryDate);
end;
end;
window.close;
if NewEntryNo = 0 then
Exit;
.. continue code ...

Explanation: This routine allows the user to use the up/down- arrows and (Shift-)Tab to move between the field.
Function window.input returns the number of the next Entry Field if the user uses an arrow or tab. It returns 0 if the user presses ESC and the same fieldnumber if the user presses ENTER.

--- Occurence of Variables ---
In Reports and Forms it's sometimes difficult to find out where a Variable has been used. Two ways to solve that:
1) Export the object as Text file and search in an editor.
2) Rename the Variable form "MyVar" to "xxxMyVar" and try to compile. The compiler will find the first occurence for you. Change the variablename on this line to xxxMyVar and continue compiling. Repeat until no further compiler errors occur.

--- Report: Read-Ahead ---
Let's assume you want to print a grouped list (e.g. Items grouped by vendor) where a new page per vendor should be started.
The NewPagePerRecord property doesn't work satisfactory as will print an empty page at the end of the report.
Therefore you have to program the page-break manually according to the rule: "If Vendor changes, start a new page providing this is not the last page."

Section Items.GroupFooter.OnPresection

Var
I : Items;

If CurrReport.TOTALSCAUSEDBY = FIELDNO("Vendor") Then Begin
I.Copy(Items);
If I.Next > 0 then
CurrReport.NEWPAGE;
end;

--- Delete Objects with Copy & Paste ---
In Object Designer you can delete a Form, Report, Dataport or Codeunit (doesn't work with Tables) by selecting it and pressing Ctrl-C/Ctrl-V at the same place. The Original as well as the Copy is history.
(Wonder why this guy doesn't simply use F4, but ok)

---

Ok, folks that's it. I hope you found something useful.

Marcus Fabian


Marcus Fabian
m.fabian@thenet.ch
+41 79 439 78 72
With best regards from Switzerland

Marcus Fabian

Comments

  • Options
    Craig_NeedhamCraig_Needham Member Posts: 23
    The tip about the Dataport request form is really great

    Thanx a million

    Craig
Sign In or Register to comment.