Fetching id based on Name
nverma
Member Posts: 396
I was wondering is it possible to fetch object id # , based on an object name.
0
Answers
-
SOLVED!
IF ISCLEAR(PDFCreator) THEN CREATE(PDFCreator); IF ISCLEAR(PDFCreatorError) THEN CREATE(PDFCreatorError); IF CreatePDF.FIND('-') THEN BEGIN REPEAT ReportName := CreatePDF."Report Name"; Object.SETFILTER(Object.Type, '%1', Object.Type::Report); Object.SETFILTER(Object.Name, ReportName); Object.FIND('-'); ReportID := Object.ID; IF Object.GET(Object.Type::Report,'',ReportID) THEN; FileDirectory := 'J:\PLM\'; FileName := ReportName +'.pdf'; PDFCreatorError := PDFCreator.cError; IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); Window.OPEN('processing'); WindowisOpen := TRUE; IF FileName = '' THEN ERROR('Please specify what the file should be saved as'); Object.GET(Object.Type::Report,'',ReportID); PDFCreatorOption := PDFCreator.cOptions; PDFCreatorOption.UseAutosave := 1; PDFCreatorOption.UseAutosaveDirectory := 1; PDFCreatorOption.AutosaveDirectory := FileDirectory; PDFCreatorOption.AutosaveFormat := 0; //PDF file, you can also save in other formats PDFCreatorOption.AutosaveFilename := FileName; PDFCreator.cOptions := PDFCreatorOption; PDFCreator.cClearCache(); DefaultPrinter := PDFCreator.cDefaultPrinter; PDFCreator.cDefaultPrinter := 'PDFCreator'; PDFCreator.cPrinterStop := FALSE; REPORT.RUNMODAL(ReportID,FALSE,TRUE); Window.CLOSE; UNTIL CreatePDF.NEXT =0; END;0 -
Just can't imagine a reason to do so
Normally you know object id (like in printer selection). 0 -
the reason I had to do it this way is because I am creating a table, where the user will enter a name of the report that he wants a pdf copy off that report. Therefore, to use this line of code in PDFCreator, I had to first figure out what the ReportID (objectID) will be for that report.
IF Object.GET(Object.Type::Report,'',ReportID) THEN;
0 -
If user will type in report name - this is bad design, users often do typo.

If user will select report name from list form, based on object - you'll got id already
0 -
Your right.
Therefore, I modified it so the user can see the list of reports that are available in the system and he can double click on the ones he want.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 324 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