Problem:
I came across situation where i needed to grab all the user-defined private views for a particular entity within the organization.
I came across situation where i needed to grab all the user-defined private views for a particular entity within the organization.
Solution:
- First of all there are two
types of views, one that is defined by user that is user's private view and
other is system defined or public views that is available to all users.
- The user defined views are stored
in "UserQuery" and the system defined views are stored in "SavedQuery"
within database.
- To get the all user defined views
for the specific entity you can execute following sql query against your
database.
select Name as ViewName ,
OwnerIdName as Owner,
case statecode when
0 then 'Active'
when 1 then 'Inactive'
end as
Status,
UserQuery.Description
from UserQuery
where ReturnedTypeCode= #entitycode(integer)
order by OwnerIdName, Name
Here
the ReturnTypeCode is the entity code that indicates the entity that is returned
as result of the view. So if you need to get all the user defined view for
account entity then you must right the
entity code for account entity.
- You can grab the system views by
going into customizations. Say you want to get the system views for
account entity then you can go to settings-> customization->
Entities-> Accounts-> Views.
- However you can also get them from
the database. You can execute following sql query against the database.
select Name as ViewName ,
SavedQuery.CreatedByName as Owner,
case statecode when
0 then 'Active'
when 1 then 'Inactive'
end as
Status,
SavedQuery.Description
from SavedQuery
where ReturnedTypeCode=10034
order by CreatedByName,
Name
Hope this helps,
Thanks
No comments:
Post a Comment