specify company in SETRANGE before DELETEALL

sam75
Member Posts: 2
Hi Guys
I have seen code where SETRANGE include a company name or id when selecting a record set as below:
Thanks
I have seen code where SETRANGE include a company name or id when selecting a record set as below:
Object.SETRANGE(Type,Object.Type::TableData); Object.SETRANGE("Company Name",COMPANYNAME); Object.DELETEALL; [img]https://us.v-cdn.net/5022383/uploads/editor/bi/xks0kbyt5ljw.png[/img]Is this necessary as I haven't use a company filter before in BC SaaS
Thanks
0
Best Answers
-
That depends on the table records you want delete.
In tablepercompany = no then you should do it.
In other cases it depends.0 -
Please note that the filter above is set on a table field named "Company Name". Most NAV tables do not have such a field, but instead have the property DataPerCompany set to it's default value which is Yes. This means, separate tables are maintained on SQL Server for each company. Unless you switch to accessing another company's data explicitly using the CHANGCOMPANY command, you only ever access the current company's data. So, no extra filtering is needed, or even possible. Even most tables that have DataPerCompany set to No do not usually have a field to filter for a company. You would rather set that property to Yes in the design of the table.
The Object table used above is a special case. The objects in general are independent of a company. Only virtual pseudo objects of type TableData are company specific in that table. And I would strongly recommend against deleting table data using this table. You should rather use a record variable of the correct subtype (or a variable of type RecordRef, if you need more flexibility), and use that variable's DELETEALL method.
0
Answers
-
That depends on the table records you want delete.
In tablepercompany = no then you should do it.
In other cases it depends.0 -
Thanks
I deleted without the company filter and as expected only applied to the logged in company (SaaS BC) but perhaps may not be the safest option0 -
Please note that the filter above is set on a table field named "Company Name". Most NAV tables do not have such a field, but instead have the property DataPerCompany set to it's default value which is Yes. This means, separate tables are maintained on SQL Server for each company. Unless you switch to accessing another company's data explicitly using the CHANGCOMPANY command, you only ever access the current company's data. So, no extra filtering is needed, or even possible. Even most tables that have DataPerCompany set to No do not usually have a field to filter for a company. You would rather set that property to Yes in the design of the table.
The Object table used above is a special case. The objects in general are independent of a company. Only virtual pseudo objects of type TableData are company specific in that table. And I would strongly recommend against deleting table data using this table. You should rather use a record variable of the correct subtype (or a variable of type RecordRef, if you need more flexibility), and use that variable's DELETEALL method.
0
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