2

I am using SOAP API client for SugarCRM in C#. I have added Web Reference of SugarCRM in my windows application. I need to get list of Leads created before particular TimeStamp. For this I am doing as follows:

try
            {
                //Fields to retrieve
                string[] Lead_fields = new string[] { "id", "name", "phone_home", "phone_mobile", "phone_work", "phone_other", "phone_fax", "deleted" ,"gclid_c"};

                LastSyncDateTime = ReadLastSyncDateTime();
                DateTime dtTemp = TimeZone.CurrentTimeZone.ToUniversalTime(Convert.ToDateTime(LastSyncDateTime));
                string sDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", dtTemp);
                string L_date_created = sDate; //LastSyncDateTime;
                string Leads_query = "(Leads.date_modified  <= " + L_date_created + ") AND Leads.deleted = 0";

                //As on 2014.11.07 (getting exception : Access Denied)
                SugarCRM.get_entry_list_result_version2 Leads_result = SugarClient.get_entry_list(SessionId, "Leads", Leads_query, "", 0, Lead_fields, null, 30, 0, true);
                if (Leads_result.entry_list.Count() > 0)
                {
                    for (int i = 0; i < Leads_result.entry_list.Count(); i++)
                    {
                        MyLeads newLead = new MyLeads();
                        newLead.LeadId = Leads_result.entry_list[i].name_value_list[0].value;
                        MyLeadsList.Add(newLead);      
                    }
                }

            }
            catch (Exception ex) 
            {
                LogMessageToFile("ERROR : " + ex.Message.ToString());
            }

Please note that I am able to login successfully as an Admin in this. Please help with this.

1
  • 1
    I have tried with string Leads_query = "(Leads.date_entered <= " + L_date_created + ") AND Leads.deleted = 0"; as well. Also I have all the permissions as a Admin role. And the module is not hidden. All fields are in Available coloumn in SugarCRM Commented Jul 12, 2014 at 7:11

1 Answer 1

2

I got it working. There aren't any docs available for this to lead you in right direction but I just made a guess and it's worked. I just quoted the L_date_created field. So the query will look like as follows :

string Leads_query = "(Leads.date_entered  <= '" + L_date_created + "') AND Leads.deleted = 0";

And whoaaa! It's working..

Sign up to request clarification or add additional context in comments.

1 Comment

which version of sugarcrm you are using, is it Sugar CRM 6.4.3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.