Run SQL Queries through Sage CRM Components

By | August 19, 2013

In our earlier post, we explained how to “Re-install the Sage CRM component” files from within Sage CRM. In this blog, we would discuss how “to execute SQL queries using Sage CRM components”.
Sage CRM components allow users to add/modify the Sage CRM screens, lists, menus, tabs etc.in a single attempt. Suppose you need to execute SQL insert/update queries using components files, then you need to add that SQL queries into the component files.
Consider an example where you want to execute below SQL update query in Sage CRM.

Update company set comp_status=’active’

Same can be written in the component files as follows.

RUNSQL(“Update company set comp_status=’active’ ”);

1. Once done, add component file into INF folder of installation directory so that component will be available to run from Sage CRM in the component manager.

Path

By default INF folder path is C:\Program Files\Sage\CRM\<<CRM Instance>>\inf\

2. Click on Install component button and screen will navigate to the confirmation screen.

Install Component

Also Read: Mapping Component Issues

3. Again click on Install Component button and component will execute the SQL queries written in it.
4. Once, components are installed properly you will get component installed message.

Installed component

5. Click on Continue button and then navigate to Administration >> System >> Metadata.
6. Select Refresh All option (other options will be selected automatically) and click on the Execute Refresh button.

Execute Referesh

7. Once done, you will get Refresh successfully executed message.

Refersh Successful

8. Log off Sage CRM and Run IISRESET command.
9. Now Login to Sage CRM again.
10. Check the status of all the companies. It will be changed to active status as we have executed SQL query through the component file.

This way any table/fields or SQL queries can be updated using component files without accessing Microsoft SQL queries.
Related Posts:

1. Sage CRM 7.2 Facebook Component
2. Mapping Component Issues
3. Control tab display using multiple SQL clauses
4. Add Divider or Subsection for existing screen in Sage CRM