• Praetorian65
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 10
    Replies
I am trying to write a soql query to return objects based on a datetime field on the object. When I try to use any of the comparison operators on the datetimes ( <, = ) I get the error "No viable alternative at character ' ' " which is ever so helpful in usual salesforce style. The error points at the comparison operator. How can I compare dates in a soql query?
Message Edited by Praetorian65 on 10-01-2009 03:38 AM

I have this error with an after update trigger in salesforce. The trigger definately does not do more than 8 SOQL queries at once and that is the most it can ever do. I am inserting objects via the API and I am doing them in batches. Does a batch of licences count towards this ie  4 queries + 4 queries + 4 queries + 4 queries + 4 queries = 22 queries = error? If so this is a pretty ridiculous limitation.

 

There are no loops or anything in the trigger.

Message Edited by Praetorian65 on 08-10-2009 09:32 AM
I am trying to create a formula field as a number. What I need to do is work out the time difference between Now and a date on my custom object rounded up to the nearest month. This would be easy to do in code but I can't work out how to do it in the formula field.

I have an auto response rule set up when a case is opened in salesforce. We are generating these through the API but it doesn't seem to work. It also doesnt work when adding a case through the salesforce UI. I added a debug log and it appears to be running the rule and sending the email but nothing actually happens:

*** Beginning Workflow Evaluation
User: ******* support
Start Time: 20090720104959.261
Starting All Rules Evaluation
Starting evaluation of rule type Assignment
Starting evaluation of rule type Response
[Case: #SL0609-000111 50020000006fnVH]
Rule Name: Ticket Responder
Evaluating Workflow Entry Criteria:
Rule entry order: 1
[Case : Status equals Opened]
Value found: Opened
Criteria evaluates to true
Spooling All Immediate Actions
[Case: #SL0609-000111 50020000006fnVH]
Response notify: ******* support, Email: support@******.com
Template: 00X200000016TbS
Ending All Rules Evaluation
Bulk Execute all Immediate Actions
Starting evaluation of rule type Workflow
Starting evaluation of rule type Escalation
End Time: 20090720104959.323
*** Ending Workflow Evaluation

 

Is there a setting that I have missed that will allow this to work? I haven't had any error messages for this (and yes, I edited the error message with asterisks for data security reasons).


Message Edited by Praetorian65 on 07-23-2009 08:16 AM
I am having trouble deleting a record via the API. I am setting the ID, IsDeleted and IsDeletedSpecified fields and the running update but it tells me that I dont have the right permissions to access those fields. The account I am using is using the system administrator profile and is also the owner of all the records of this custom object. I can't find any settings anywhere that appear relevent to this issue. I have raised a support case but I don't hold much hope for a reply.
Is there any way in a trigger to determine if the object is being created/edited due to an API call as opposed to via the salesforce ui? I have some custom objects that I need to prevent any editing of via the salesforce UI. 

I used ant with the force.com migration tool to migrate some developer sandbox changes to our full sandbox and one of our picklists does not work. It is on the account object and it either isn't selectable or has only one value to select. The actual picklist was set up with two values with no validation and no dependencies. When we first migrated our changes it wasn't editable. I then set it to NOT be a required field on the page layouts and that made it editable. For some reason it still only had one selectable value though. I then set up a dependency that made all options available for all possible values of the parent field. This allowed both options to be selected for one account but when I went to another account it had only one selectable value again. I then changed the account type (the parent field) and this left no selectable values in the child picklist. This is not what it is set up to do. What is going on here?

 

EDIT: The picklist works fine in the controlling field preview, but not on the actual account pages. This is crazy.

Message Edited by Praetorian65 on 06-15-2009 02:21 AM
Quick question, when deploying changes with the migration tool for lets say Accounts, if I dont specify a custom field will it be created, or will the tool just create the fields I specify and ignore the ones I dont?

Is there a way to increase the timeout on an outbound message? I have an outbound message that generates product data on an external database but with a large amount of products this takes time. If the webservice times out it causes the data to be generated again. This is very very bad.

 

I could return immediately and process asynchronously but this defeats the object of outbound messaging. Just because the webservice is active it doesn't mean it will succeed.

  

I am trying to access the salesforce production environment using the eclipse plugin. I can do this with the sandbox but it doesn't appear to recognise my login credentials when I try to go into production. I can login fine via the web but in the logs for my user it says "Invalid Password" next to my login attempt. My password was not wrong and neither was my security token. What is going on here?
Is there currently any way to schedule an apex script in Salesforce? I have seen CronKit but first I want to find out if it is possible without installing extras.
I have a Visualforce page that contains a javascript function:
 
Code:
       function reportSuccessOrFail()
        {
          try {
                 var success = sforce.apex.execute("ReadResult","GetResult",{});
                
                if(success ==true)
                    alert('Salesforce data successfully updated');
                else
                    alert('There was an error with the update');
                
            } catch (e) {
                alert(e.name + ' ' + e.message);
            }
        }

This uses the following apex class:

Code:
global class ReadResult{
    webservice static boolean GetResult()
    {
        boolean returnresult = false;
    
        DateTime timefrom = DateTime.now();
        DatabaseRequest__c[] dbr = [select Result__c from DatabaseRequest__c order by Time__c desc];
        
        if(dbr.size()>0)
        {
            returnresult  = dbr[0].Result__c;
        }
        
        return returnresult;
    }
} 

 
When I run it I get the error: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 
How do I fix this?


Message Edited by Praetorian65 on 01-07-2009 06:05 AM
I have a tab called "Networks". Is it possible to build a visualforce page that has perhaps a small bit of custom content at the top and then load the network list view, or would I have to build my own view from scratch?
 
(If you hadn't guessed im brand new to this).
 
Thanks in advance.
 
Edit - Solved - found the listviews in the reference.


Message Edited by Praetorian65 on 01-07-2009 02:19 AM
I have an apex script (ReadLicenses) that updates SF objects from my external db using a static Read() method. Is it possible to have a button somewhere that can activate the script or atleast schedule it to run?
Error: Compile Error: Initial term of field expression must be a concrete SObject: Datetime at line 53 column 61
 
Apex is driving me up the wall. I am trying to convert from a datetime to a date. Line 53 is in bold. It will not let me use licenseArray[i].StartDate to access the date (licenseArray is an array of License objects). I have successfully used licenseArray[i].StartDate in the creation of a custom object (License__c) but I need to change this object to have Date fields instead of DateTime. I am getting the data from a webservice which provides DateTime. StartDate and EndDate can both be null. How can I fix this?
 
Code:
        try{
            While(licenseArray.Size() > 0)
            {               
                for(Integer i = 0; i < licenseArray.Size(); i++)
                {
                    date endD;
                    date startD;
                    
                    if(licenseArray[i].StartDate != null)
                    {
                        //DateTime startDateTime = licenseArray[i].StartDate;
                        Integer startYear = licenseArray[i].startDate.Year;
                        Integer startMonth = licenseArray[i].startDate.Month;
                        Integer startDay = licenseArray[i].startDate.Day;
                        startD = date.newinstance(startYear,startMonth,startDay);
                    }
                    if(licenseArray[i].EndDate != null)
                    {
                        DateTime endDateTime = licenseArray[i].EndDate;
                        Integer endYear = endDateTime.Year;
                        Integer endMonth = endDateTime.Month;
                        Integer endDay = endDateTime.Day;
                        endD = date.newinstance(endYear,endMonth,endDay);
                    }
                                   
                    
                    License__c newLicense = new License__c(ContactName__c = licenseArray[i].ContactName, NetworkCode__c = licenseArray[i].NetworkCode, Period__c = licenseArray[i].Period,
                                            Number__c = licenseArray[i].Number_x, EndDate__c = endD, StartDate__c = startD);
                                            
                                            
                    myList.Add(newLicense);
                    if(myList.Size() == 1000)
                    {
                        myListList.Add(myList);
                        myList = new List<License__c>();
                    }
                    
                }   
                index = index + count;
                licenses = data.GetLicenseData(index,count);
                licenseArray = licenses.License;
            }
            
        } catch (Exception ex)
        {
            
        } 

 
I have a custom object called License. I also have an external asp page that will dynamically generate some XML with most of the data needed to create a new License object (one field I have to work out from the others, but nothing too hard). I need to write some code that can import the data say once a day but I have no idea how to go about doing this. None of the documentation I've read hints at anything like this. I don't know where to start.
I have an asp page on a webserver that dynamically generates xml from a mysql database. The xml basically contains license information for which I have created a custom object in salesforce. How do I go about importing this data so the license information can be kept up to date automatically?


Message Edited by Praetorian65 on 12-18-2008 03:50 AM

Message Edited by Praetorian65 on 12-18-2008 03:50 AM
I am trying to create a formula field as a number. What I need to do is work out the time difference between Now and a date on my custom object rounded up to the nearest month. This would be easy to do in code but I can't work out how to do it in the formula field.

Hi, I am a .net developer and new to salesforce.

I want to add the webservice api to my project.

But  I am unable to start.

Is there any video or step by step tutorials for this ?

 

  • June 19, 2009
  • Like
  • 0

Is there a way to increase the timeout on an outbound message? I have an outbound message that generates product data on an external database but with a large amount of products this takes time. If the webservice times out it causes the data to be generated again. This is very very bad.

 

I could return immediately and process asynchronously but this defeats the object of outbound messaging. Just because the webservice is active it doesn't mean it will succeed.

  

I am trying to access the salesforce production environment using the eclipse plugin. I can do this with the sandbox but it doesn't appear to recognise my login credentials when I try to go into production. I can login fine via the web but in the logs for my user it says "Invalid Password" next to my login attempt. My password was not wrong and neither was my security token. What is going on here?
Hi, I am new to apex trigger programming, though a long-time programmer.

I would like to track the date and time of day when tasks are marked "Completed". This functionality is not captured by Due Date or Date of Last Activity.

trigger DateCompleted on Task ( before insert, before update )
{
try
{
// task.DateCompleted = todaysDate();
// task.TimeCompleted = now;
}
catch ( Exception ex )
{
}
}

I'd appreciate your help on this - also (and related), I looked around for some time, but could not find a resource with a bunch of example Apex triggers - this would be really helpful.
  • January 13, 2009
  • Like
  • 1
Hi
I have found an exception :

System.Exception: Too many SOQL queries: 101
I explain my problem with simple example.This example look like as my application:

public class class1
{
    void show()
    {
        for(Integer i=0;i<5;i++)
        {
            Double d1=class2.getData();
            Double d2=class3.getData();
        }
    }
public pageReference save()
{
show();
}
}




// Another Apex class


global class class2
{
    Webservice static Double getData()
    {
        Double d=0.0;
        for(Integer i=0;i<12;i++)
        {
            // perform SOQL Query
            //just like......
            for(Object__ c:[select id__c from Object__c])
            {
                d=c.id__c;
            }
        }
        return d;
    }
}

// Another Apex class



global class class3
{
   
Webservice static Double getData()
    {
        Double d=0.0;
        for(Integer i=0;i<12;i++)
        {
            // perform SOQL Query
            //just like......
            for(Object__ c:[select id__c from Object__c])
            {
                d=c.id__c;
            }
        }
        return d;
    }
}


When i call save() from visual force page i am getting exception Too many SOQL queries.
Please solve my problem.

Thanks & Regards
Brijesh Kumar Baser

A : List<Account> flstAccount = new List<Account>([select id from account]);
B: List<Account> flstAccount = [select id from account];

 What is the difference between A and B?

thank you.


Message Edited by china.leaf on 01-12-2009 11:24 PM
I have a Visualforce page that contains a javascript function:
 
Code:
       function reportSuccessOrFail()
        {
          try {
                 var success = sforce.apex.execute("ReadResult","GetResult",{});
                
                if(success ==true)
                    alert('Salesforce data successfully updated');
                else
                    alert('There was an error with the update');
                
            } catch (e) {
                alert(e.name + ' ' + e.message);
            }
        }

This uses the following apex class:

Code:
global class ReadResult{
    webservice static boolean GetResult()
    {
        boolean returnresult = false;
    
        DateTime timefrom = DateTime.now();
        DatabaseRequest__c[] dbr = [select Result__c from DatabaseRequest__c order by Time__c desc];
        
        if(dbr.size()>0)
        {
            returnresult  = dbr[0].Result__c;
        }
        
        return returnresult;
    }
} 

 
When I run it I get the error: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 
How do I fix this?


Message Edited by Praetorian65 on 01-07-2009 06:05 AM
Error: Compile Error: Initial term of field expression must be a concrete SObject: Datetime at line 53 column 61
 
Apex is driving me up the wall. I am trying to convert from a datetime to a date. Line 53 is in bold. It will not let me use licenseArray[i].StartDate to access the date (licenseArray is an array of License objects). I have successfully used licenseArray[i].StartDate in the creation of a custom object (License__c) but I need to change this object to have Date fields instead of DateTime. I am getting the data from a webservice which provides DateTime. StartDate and EndDate can both be null. How can I fix this?
 
Code:
        try{
            While(licenseArray.Size() > 0)
            {               
                for(Integer i = 0; i < licenseArray.Size(); i++)
                {
                    date endD;
                    date startD;
                    
                    if(licenseArray[i].StartDate != null)
                    {
                        //DateTime startDateTime = licenseArray[i].StartDate;
                        Integer startYear = licenseArray[i].startDate.Year;
                        Integer startMonth = licenseArray[i].startDate.Month;
                        Integer startDay = licenseArray[i].startDate.Day;
                        startD = date.newinstance(startYear,startMonth,startDay);
                    }
                    if(licenseArray[i].EndDate != null)
                    {
                        DateTime endDateTime = licenseArray[i].EndDate;
                        Integer endYear = endDateTime.Year;
                        Integer endMonth = endDateTime.Month;
                        Integer endDay = endDateTime.Day;
                        endD = date.newinstance(endYear,endMonth,endDay);
                    }
                                   
                    
                    License__c newLicense = new License__c(ContactName__c = licenseArray[i].ContactName, NetworkCode__c = licenseArray[i].NetworkCode, Period__c = licenseArray[i].Period,
                                            Number__c = licenseArray[i].Number_x, EndDate__c = endD, StartDate__c = startD);
                                            
                                            
                    myList.Add(newLicense);
                    if(myList.Size() == 1000)
                    {
                        myListList.Add(myList);
                        myList = new List<License__c>();
                    }
                    
                }   
                index = index + count;
                licenses = data.GetLicenseData(index,count);
                licenseArray = licenses.License;
            }
            
        } catch (Exception ex)
        {
            
        }