How to retrieve data from entity (table) in SageCRM?

by Raju Maharjan 1. December 2010 22:01

With queryrecord method you will be able to retrieve the list of the records from entity. It is pretty simple to build your own SQL query while dealing with the queryrecordRequest  object of your web service. All you need to do is set fieldlist, entityname, queryString ,orderby and SessionHeader  properties exposed in the object and you will build your custom query to retrieve records for the entity.

SessionHeader crmSessionHeader = new SessionHeader();

WebServiceSoapPort CRMService = new WebServiceSoapPortClient();

void GetAllRecordsInEntity()

        {

            string listofFields = "";// blank will return all the fields or you can set the comma separated column names;

            string whereClause = "";//" blank for no condition or set as "type='user'" for condition

            string entityName = "Users";// Define entity name (which is a database table) here 

            string orderBy = "";// set  order by with desired column

 

            queryrecordResponse objQueryRecordResponse = new queryrecordResponse();

            queryrecordRequest objQueryRecordRequest = new queryrecordRequest();

            objQueryRecordRequest.fieldlist = listofFields;

            objQueryRecordRequest.entityname = entityName;

            objQueryRecordRequest.queryString = whereClause;

            objQueryRecordRequest.orderby = orderBy;

            objQueryRecordRequest.SessionHeader = crmSessionHeader;            

            objQueryRecordResponse = CRMService.queryrecord(objQueryRecordRequest);

            queryrecordresult myQueryRecordResult = objQueryRecordResponse.result;            

            crmrecord[] myRecordList = myQueryRecordResult.records;            

            for (int i= 0; i< myRecordList.Length; i++)

            {

                recordfield[] myFieldList = myRecordList[i].records;

                for (int j= 0; j< myFieldList.Length; j++)

                {

                    recordfield myField = (recordfield)myFieldList[j];

                   //use myField.name for column name and  myField.value for value field

                }

            }

        }

 

Domain Registration, Web Hosting and Web Services 
Domain Registration, Web Hosting and Reseller Web Hosting 
Start Web Hosting from just $2.5/Month

Tags: , , ,

SageCRM

How to set MaxReceivedMessageSize property in Sage CRM Service application?

by Raju Maharjan 1. December 2010 18:30

If you even faced the exception message as below while developing application using SageCRM web services then here is the solution.

"To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."

Find  the below section in your app.config or web.config within your application.

<system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <binding name="WebServiceSoapBinding" closeTimeout="00:01:00"

                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                    useDefaultWebProxy="true">

                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="None">

                        <transport clientCredentialType="None" proxyCredentialType="None"

                            realm="" />

                        <message clientCredentialType="UserName" algorithmSuite="Default" />

                    </security>

                </binding>

            </basicHttpBinding>

        </bindings> 

You can find the property as maxReceivedMessageSize="65536"  which is set by default to 65536. You may change this property as per your need.

 

Domain Registration, Web Hosting and Web Services 
Domain Registration, Web Hosting and Reseller Web Hosting 
Start Web Hosting from just $2.5/Month

Tags: ,

SageCRM

How to Logon / Logoff using Web Service in Sage CRM and Add Service Reference?

by Raju Maharjan 30. November 2010 19:08

If you have used 'Add Service Reference' to connect to a Sage CRM with VS2008 then you will be using the WebServiceSoapPort class. Before beginning with the development firstly add reference to the web service by simply right clicking the project solution explorer and then Add Service Reference. The below window appears and put you reference URL.

How to Logon using Web Service in Sage CRM and Add Service Reference?

 

Log on (WebServiceSoapClient)

WebServiceSoapPort SageCRMService = new WebServiceSoapPortClient();
logonRequest objLogonRequest = new logonRequest();

//Set your CRM Username and Password
objLogonRequest .username = "CRMAdminUser";
objLogonRequest .password = "yourCrmPassword";
logonResponse objLogonResponse = SageCRMService .logon(objLogonRequest );

SessionHeader objSessionHeader = new SessionHeader();
objSessionHeader.sessionId = objLogonResponse .result.sessionid;

Log off (WebServiceSoapClient)

logoffRequest objLogoffRequest = new logoffRequest();

objLogoffRequest .SessionHeader = objSessionHeader;
objLogoffRequest .sessionId=objLogonResponse .result.sessionid;
logoffResponse objLogoff = SageCRMService.logoff(objLogoffRequest);

By implementing in code as above you will be able to Logon and LogOff in SageCRM. The steps are pretty simple to use but make sure that the logon user must have Web Service access and CRM Web Services are setup.

To set up a user for Web Services:

1. Select Administration | Users | Users and find the user who you want to be able to access

Web Services.

2. Select the hypertext link for the user and select the Change action button.

3. Scroll down to the Security Profile panel, set the Allow Web Service Access field to True.

4. Select the Save button.

 

Domain Registration, Web Hosting and Web Services 
Domain Registration, Web Hosting and Reseller Web Hosting 
Start Web Hosting from just $2.5/Month


Sapnep IT Solution

We Provide IT solutions and services to deliver a unique blend of real-business experience with a strong engineering, international project delivery. We are a software development  firm.