Loop of function not desired

Alva1
Member Posts: 24
Hi,
I open a STRMENU window through a function in a codeunit which set the users choice and save it in a Variable.(integer form 1 to 4)
This codeunit calls the Contact rec.
It works fine but it runs in a loop stage(finds a contact and ask through the menu to set a choice over and over again).
What i wanted to do is to set this choice just once and keep that chosen integer(for example 1)for all the contacts, and then through IF THEN statements run different operations:
IF Variable = 1 THEN
DO THIS;
IF variable = 2 THEN
DO THIS
Is there a possibility to achieve this???
I open a STRMENU window through a function in a codeunit which set the users choice and save it in a Variable.(integer form 1 to 4)
This codeunit calls the Contact rec.
It works fine but it runs in a loop stage(finds a contact and ask through the menu to set a choice over and over again).
What i wanted to do is to set this choice just once and keep that chosen integer(for example 1)for all the contacts, and then through IF THEN statements run different operations:
IF Variable = 1 THEN
DO THIS;
IF variable = 2 THEN
DO THIS
Is there a possibility to achieve this???
Best regards
Alva1
Alva1
0
Answers
-
ModifyAll(Field, newvalue,[runtrigger]) modifies the value for the specified field for all the records in a specified Range/Filter.
For the not looping, you could write your own function, instead of calling the codeunit0 -
Hi Sog,
Thank you for your quick response!
My first initial thought was to run the STRMENU through a form, so the variable would be set only once.
What i don't really know how to do is to give the value of the variable to the codeunit(so the codeunit take the variable and runs the function using the given value!)
any tips or ideas??Best regards
Alva10 -
Hi Alva1,
Can you put a part of the code you're trying to do here?
It's hard to understand what you really want/need... :-kMarcelo Borges
D365 Business Central Solutions Architect
BC AL/NAV C/AL Developer
BC Repositories.com0 -
If you design the codeunit with the function, go to the c/al globals, tab functions.
Select the function you want to use and click on 'locals'.
There you see in the first tab (parameters) which parameters the function requires.
If there aren't any parameters, you can't pass along parameters unless you edit that function. (not recommended)
If you just run the codeunit, the 'run' function does not have any parameters thus you can't pass along parameters.
to pass along parameters use something like this
var_cu (global or local variable of the type codeunit and subtype the codeunit you want to use)
var_int (your integer which represents the option?)
var_cu.function(var_int); //<- this line calls the codeunit's function with the integer as parameter0 -
It means that you have wrong design of the process. The value selection must be made before the loop. It seems you have it as part of the loop... but without the code....0
-
Alva1 wrote:Is there a possibility to achieve this???0
-
Hi Thank you for all the answers!
but i think i didn't explain it very well so ill do it better this time:
is about the Outlook Synchronisation.
When the user opens the Salesperson Purchaser card, there is this outlook Synch tab, what i wanted to do is when people press this button to synch(or sometime between the whole process) a MESSAGE pops out and ask the user how does he want to save the contacts in Outlook, automatically after that the STRMENU pops out showing 4 options
1)option 1
2)Option 2
3)Option 3
4)Option 4
If the user press cancel, the form will automatically close.
I managed to do this, but now comes the tricky part:
The Codeunit 5069 Outlook Contact Handler is the one incharge of creating contacts in Outlook, and there is this function ASSIGN which is incharge of assign the different navision fields to Outlook.
For example:
OlContactFileAs := Cont.Name
here is where i write some IF THEN statements to set how the contacts should be saved in Outlook
For example:
IF OptionChoosenFromUser = 1 THEN
OlContactFileAs := Cont."Company Name"+' '+Cont.Name;
IF OptionChoosenFromUser = 2 THEN
OlContactFileAs := Cont.Name
and so on.
what i wanted is to save somehow the Option choosen from the user and use it for every loop in this function ASSIGN.
but i don't really know how to do this and which is the best way!Best regards
Alva10 -
It means, that the user will select the option only once, and after that, the process will go automatically with this setting each time? If yes, you need to store the value into some table (e.g. user setup) and read it from there.
And one tip: try to use CASE statement instead
if something = x then
if something = y then0 -
Thank you guys for helping me out everything worked perfectly out!Best regards
Alva10
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions