- Sample String: TEST
- Left(TEST,2) = COPYSTR('TEST',1,2)
- Right(TEST,2) = COPYSTR('TEST',STRLEN('TEST')-2,2)
- Convert to string
- Format(MyVar, 15)
- Remove all whitespace to the left
- DELCHR(Format(MyVar, 15),'<',' ')
- Convert String to Number
- Setup MyVar as global int
- Evaluate(MyVar, StringToConvert)
- MyVar is populated with int value of StringtoConvert
- How to cycle through records to get anything you need
- Create global variables for the Tables and Variables you wish to track
- Table Records
- Eg. Itm>Rec>Item Table
- SH>Rec>Sales Header Table
- Variables
- InvNo>Text>30
- CusNo>Text>30
- Use this code to find what you need Aftergetrecord
- Assuming we're setting the InvNo to some value, then cycling through the SH to find the Customer numbers
- InvNo := 'INV000234'; //Sets value of InvNo
- SH.SETRANGE("No.",InvNo); //Filters the SH table where No. = InvNo
- If SH.FIND('-') THEN //Starts to cycle through the filtered recordset. If it finds a record, move on
- BEGIN //Start If Begin..End block
- REPEAT //Start repeat loop
- CusNo := SH."Customer No."; //Sets the CusNo variable to the "Customer No." field for the current record it's on
- UNTIL SH.NEXT = 0; //ends loop when there are no more records
- END; //Closes If BEGIN..END block
- This code can be used in a page or report to cycle through each aftergetrecord isntance to get the customer number for that specific record, then display it
- To display it, simply insert a new line, and type in the Variable name in the column source and caption of your page or report
- To reload a record from the database, or refresh data for a record, use the GET() function
- Set a range using a date (all dates from 0D to 14D before today)
- customer.setrange("Created date", 0D ,CALCDATE('<-14D>',TODAY))
- Use date values
- DATE2DMY(31,12,1900)
- Filter to blank dates only
- IAE.SETFILTER(OrigInboundDate,0D);
- filter to nonblank dates only
- IAE3.SETRANGE(OrigInboundDate,0D,TODAY);
- SETRANGE on date
- ILE.SETFILTER("Posting Date",'%1..%2',PeriodStartDate[Bucket],PeriodStartDate[Bucket+1]);
- Check if you are at the last record in a list
- customer.LASTRECORD
- Setrange on an option field
- vendor.SETRANGE(vendor."Application Method",vendor."Application Method"::"Manual");
- vendor.SETRANGE(vendor."Application Method",vendor."Application Method"::" ");
- Setfilter using wildcards (*) and case insensitive (@)
- SETFILTER(Description,'@*'+ItemDescFilter+'*');
- Use COMMIT at the end of your REPEAT..NEXT loops to prevent table locking and complete rollback of all records if an error occurs
- The routine runs slower, but will not lock up tables, and will not roll back ALL changes if the routine errors out or is cancelled
- Set the focus to a subform
- CurrPage.SalesLines.PAGE.ACTIVATE;
Thursday, April 23, 2015
Dynamics NAV - CAL Notes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment