• spraetz
  • SMARTIE
  • 1125 Points
  • Member since 2008

  • Chatter
    Feed
  • 40
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 178
    Replies

Hi,

I want to get all field names and object names in my Org.I am using "getGlobalDescribe" and "fields.getMap" in my apex code.but with this code i can access only upto 100 objects,if i am trying to access more than 100 objects it is throwing me error.

 

Kindly let me know is there any work around for this.

 

Thanks,

We have an existing class that uses the Test.isRunningTest() method.  Today we tried making changes to that class (completely unrelated to the isRunningTestMethod) and weren't able to save it because of a "method doesn't exist or incorrect signature" error on that method.  Did something change with the Winter 12 release where we can no longer use this in code?  If so, is there something replacing this functionality?  If we should still be able to use it, any thoughts on why we are receiving this error now?


Save error: Method does not exist or incorrect signature: Test.isRunningTest()


  • October 27, 2011
  • Like
  • 1

Hello, i have a small problem...

I want to update a list like this, but it doesnt work.

 

                List<obj__c> list = [SELECT Value__c,Masterobj__r.otherValue__c FROM obj__c ];

                for(obj__c i : list){
                        i.Value__c = true;

                        i.Master__r.otherValue__c = true;

 

                }    
                update list;

 

Value__c becomes true but not    Master__r.otherValue__c. Where is my mistake?

Hi,

 

i have a class that i run from system log screen ervery month. it was working fine but all of a suddon it has started giving errors as below.

 

 

*********************************** Error Log******************************

 

Apex script unhandled exception by user/organization: 00520000001grzo/00D20000000BaRL

 

Failed to process batch for class 'clsInvoiceRun' for job id '7072000000AspWh'

 

caused by: System.DmlException: Insert failed. First exception on row 12; first error: INVALID_CROSS_REFERENCE_KEY, Owner ID: owner cannot be blank: [OwnerId]

 

Class.clsInvoiceRun.execute: line 180, column 9

External entry point

 

Debug Log:

6 (476287000)|SYSTEM_METHOD_ENTRY|[163]|MAP.containsKey(ANY)

14:53:05.476 (476365000)|SYSTEM_METHOD_EXIT|[163]|MAP.containsKey(ANY)

14:53:05.476 (476400000)|STATEMENT_EXECUTE|[163]

14:53:05.476 (476458000)|VARIABLE_ASSIGNMENT|[161]|i|103

14:53:05.476 

.

.

.long list continue.....

.

.

14:53:05.818 (818405000)|WF_RULE_FILTER|[Invoice : Invoice Status equals Finance Approved]

AND [Invoice : Record Type equals Invoice Stage 2]

14:53:05.818 (818527000)|WF_RULE_EVAL_VALUE|1

14:53:05.818 (818595000)|WF_CRITERIA_END|false

14:53:05.818 (818681000)|WF_SPOOL_ACTION_BEGIN|Workflow

14:53:05.818 (818828000)|WF_ACTION| None

14:53:05.818 (818897000)|WF_RULE_EVAL_BEGIN|Escalation

14:53:05.818 (818960000)|WF_RULE_EVAL_END

14:53:05.819 (819194000)|WF_ACTIONS_END| None

14:53:05.819 (819278000)|CODE_UNIT_FINISHED|Workflow:01I20000000cVKI

14:53:05.820 (820086000)|DML_END|[180]



 

any help will be appriciated

 

thanks,

 

email.toAddresses.contains('teameast@2p0b7hdjfv8olr8hubm9unhg.37creai.7.case.salesforce.com'))

 

Save Error: Method does not exist or incorrect signature: [List <String>].contains(String)

 

how do i check to see if the to.Addresses field contains that string/email?

I am looking for help.

 

I have written a test program for an Apex trigger. The program creates a test account and an opportunity

that is associated with it. The code is shown below:

        // Create a test account for 'Corp Admin'
        Account testAccount = new Account
        (
            Name = 'Test Account',
            Owner = [select username from user where username = 'Corp Admin']
        );
        
        insert testAccount;
        
        // Create a forecast opportunity
        Opportunity testOpp = new Opportunity
        (
            AccountId = testAccount.ID,
            Name = 'testOpportunity' + date.today(),
            CloseDate = date.today() + 1,                    
            StageName = 'Contract signed; waiting for P.O',
            Type = 'Existing Business',
            Pricebook2Id = [select Id from Pricebook2 where name = 'Standard Price Book'],
            OwnerId = testAccount.OwnerId
         );
         
         insert testOpp;
         

 In the program, I want to set the appropriate Price Book, so that I can later enter line items from a specific price book.

The line:

Pricebook2Id = [select Id from Pricebook2 where name = 'Standard Price Book']

is used for this purpose.

 

When compiling, I get the error:

Invalid initial expression type for field Opportunity.Pricebook2Id, expecting: Id.

 

How would I get the Id for the price book?

 

In the same way, I am using the following, to enter a line item (OpportunityLineItem) for the opportunity:

PricebookEntryId = [select Id from Product2 where name = 'AC02'],

 

I get the same kind of error.

 

         Thanks,

 

                aqueller

 

I have a date time string from external system that is represented as 10/13/2011 10:36:07 AM

Need to put it in datetime field on sf object. when try to do datetime.parse ('10/13/2011 10:36:07 AM'); it gives me type exception, invalid date time... any workarounds?

  • October 14, 2011
  • Like
  • 0

Hi ,

I am looking for an advice on how to approach for this case.

 

I have to synchronize the salesforce Account object into My application. While synchronize, I am generating unique value in my application for newly created account. That unique value needs to update in salesforce.

 

I am using HttpCallout to make request and get response. I am raising request from Apex trigger. This implementation works fine when we are creating or updating single object.

 

Sometimes we are creating bulk account object in saleforce using third party tool.  That time I am getting “Too many future callout expection”, because it exceeds callout limitation.

 

Now I am planning to implement using Batch Apex.

 

 Is it good approach start the batch apex inside the trigger?  Because I don’t like having button in vf page and start batch apex by clicking that button. I want that synch process should be automatic not manual.

 

Is it good using batch apex for updating single entity?

 

Is active batch apex limitation for User specific or salesforce instance?



 

Given that @future execute async, I suspect there are not guarnantees, but I thought I would ask:

 

I am in a before insert trigger and I call @future.

 

Is there any guarantee that my insert trigger (the current transaction thread) will complete before the async. method is called.

 

 

 

how to write trigger on Oppurtunity related list Sales team object

 

 

  • October 13, 2011
  • Like
  • 0

Hi,

 

I have done some triggers in my sandbox isntance; when i tried to deploy these triggers from Sandbox to Production, I got the error that the Api version in my Production Org is 22.0, this is because my sandbox is on Winter 12 and Production is still in Summer 11,  this will be solved this weekend

:))

 

My question is......I have tried also to do it with Eclipse, and it saids that my version is 20.0

 

How can up upgrade to 23.0?

Thanks!!!

  • October 11, 2011
  • Like
  • 0

Hi everyone,

 

I've been altering some integration code and now I get the dreaded "You have uncommitted work pending. Please commit or rollback before calling out" message.  This is supposed to indicate I have begun an update or insert and subsequently made a callout.

 

The code I started with is very OO and it's hard to figure out exactly what is getting run when.  So after a while I started copying the code into a refactored base so I can tell exactly what is going on.  I am now at the point where my code has no DML at all, I'm not even doing a select and I still get the error.  Code is below.

 

I have to think one of two things is happening. Either the error message is incorrect or something is "stuck."  I don't have solid evidence for the latter idea but this error message has come and gone a couple of times without any obvious action on my part.

 

As I search this error message I only find people who actually were doing DML before the callout.  Clearly I am not.  Am I special?  I hope someone else has faced this.

 

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

// execute this line in an anonymous block to see the error non-fun

CalloutLaidBare.toddWillMakeItHappen();

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// here's the class

public with sharing class CalloutLaidBare {


    public static void toddWillMakeItHappen() {

        Map<String, String> params = new Map<String, String>();
        params.put('master_plan_no', '10266411');
        params.put('master_plan_units', '1');

        // etc, all hard-coded values

        // normally I'd be parsing values from an opportunity which is why this is seperate from the future method


        String qs = makeStringFromMap(params);  // this works
        CalloutLaidBare.makeItHappenCallout(qs);

 

    }

    @future(callout=true)
    public static void makeItHappenCallout(String qs) {

        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('hard-coded endpoint');
        req.setMethod('POST');
        req.setBody(qs);

        try {
            HttpResponse res = h.send(req);

            // why bother parsing, I'll never get here

 

        } catch (Exception e) {
            // email myself e.getMessage() and drown my sorrows in chocolate
        }

    }


}

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



 

I am invoking external service to update Account information into my  DB. This service will be invoked  while creating,updating and delete an Account.. This works fine if i logged as administrator user.  But Apex method is not invoking if i logged as other than administrator. Do i need use global access specifier?

In the stack panel, there is a number in parens after each time stamp. What does this number represent? It doesn't seem to be milliseconds or statements executed.

 

 

 

 

How to find out the  open lab activities ?

i'm trying to understand how the script statement limit governor is enforced for batch apex.  the governor limits as described in sf are 200k statements and 1M statements for batch apex and future methods.

 

my question is whether the 1M statements for batch apex applies to the total statements processed for all batches/transcations or applies separately to each batch/transaction.

 

so, if i have 20 batches and each batch processes 100k statements, is that going to count as 100k and never trip the limit or 2M statements and trip the limit?

  • October 04, 2011
  • Like
  • 0

Is there a way to query for any profiles which have "View Encrypted Data" permission enabled? That permission doesn't show up in the schema like, for example, PermissionsModifyAllData does so I'm wondering if it's exposed in any way.

Good morning everyone.

I wonder how I can create a trigger that after Savar an object, it redirects me to create a new object?

I appreciate the answers.


Hey I am facing a view state error. I checked in the view state option and it shows that the query which i use returns around 2500 records which jump the limit of 135 Kb. are there any workarounds other that putting a limit on the query.

I'm trying to create an XML document from a select set of fields of an object. I decided to use XmlStreamWriter class.

 

To write <fieldlabel1>fieldlabel1_value</fieldlabel1>

              <fieldlabel2>fieldlabel2_value</fieldlabel2> and so on

 

I made a List<string> fieldstoInclude that has all the fields to include in XML

 

              for(String s : fieldstoInclude){
                 w.writeStartElement(null,s,null);
                 //how to write value?
                 w.writeEndElement();
                }

My question here is, since WriteCharacter only takes Text and fields of an object can be of varying types, what is the best way to go ahead and do this?

 

I was thinking of making a map<string,string> with field labels as Map's keys and field values converted into strings as Map's value. There are hundereds of fields and I don't want to write code to convert each field manually. Is there a way to do this?

 

Any help will be greatly appreaciated.

 

Thank you,

Sunny_Slp

Imagine enabling the power of the Page Layout Editor for your own custom-coded Visualforce pages.

 

Field Sets combined with the new Dynamic Binding in Visualforce allow you, the developer, to create Visualforce pages such that the fields that are displayed (and the order in which they are displayed!) are modifiable by non-technical adminsitrators via out-of-the-box point-and-click tools.

 

Field Sets are currently in open Beta -- which means that everyone can use them today!  You will find them on standard objects as well as custom objects!

 

A Field Set is a collection of fields that can be iterated over in an <apex:repeat> tag.  As a developer, you will have control over which fields are initially present in the Field Set as well as which fields the administrators can put in the Field Set after installing the package. 

 

Here is a link to a blog post with some sample code for using a field set: http://blog.sforce.com/sforce/2011/02/using-field-sets-in-spring-11.html

 

Field Sets in the Metadata API: http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_fieldset.htm

 

Field Sets in the Spring '11 release preview webinar: http://wiki.developerforce.com/index.php/Spring_11_release_webinar_archive

 

About Field Sets (Need to be logged in): https://help.salesforce.com/apex/HTViewHelpDoc?id=fields_about_field_sets.htm&language=en

Creating and Editing Field Sets (Need to be logged in): https://help.salesforce.com/apex/HTViewHelpDoc?id=fields_editing_field_sets.htm&language=en

If you have any questions about use cases, code, or anything else.  Please feel free to post here and I'd be happy to help!

 

-Ryan

I am making this callout to CrunchBase 

 

HttpRequest[Endpoint=http://api.crunchbase.com/v/1/search.js?query=square, Method=GET]

 

and getting this JSON Response and error, Seems I need to wipe out a bad char, but how to find the one ? how should I get rid of this one ? 

Also checked char location 26924 in VIM, its end of string.

 

16:47:53.321 (321102000)|FATAL_ERROR|System.JSONException: Illegal unquoted character ((CTRL-CHAR, code 11)): has to be escaped using backslash to be included in string value at input location [26,924]

 

16:47:53.237 (237876000)|USER_DEBUG|[6]|DEBUG|{"total": 253,
 "page": 1,
 "crunchbase_url": "http://www.crunchbase.com/search?query=square",
 "results":
  [{"name": "Square Enix North America",
    "permalink": "square-enix-north-america",
    "crunchbase_url": "http://www.crunchbase.com/company/square-enix-north-america",
    "namespace": "company",
    "overview": "Square Enix, Inc. develops, publishes, distributes and licenses SQUARE ENIX, EIDOS and TAITO branded entertainment content throughout the Americas as part of the Square Enix Group. The Square Enix Group operates a global network of leading development studios and boasts a valuable portfolio of intellectual property, including: FINAL FANTASY\u00ae, which has sold over 97 million units worldwide; DRAGON QUEST\u00ae, which has sold over 54 million units worldwide; TOMB RAIDER\u00ae, which has sold over 35 million units worldwide; and the legendary SPACE INVADERS\u00ae. Square Enix, Inc. is a U.S.-based, wholly-owned subsidiary of Square Enix Holdings Co., Ltd.",
    "image":
     {"available_sizes":
       [[[150,
          12],
         "assets/images/resized/0012/4564/124564v1-max-150x150.png"],
        [[250,
          21],
         "assets/images/resized/0012/4564/124564v1-max-250x250.png"],
        [[273,
          23],
         "assets/images/resized/0012/4564/124564v1-max-450x450.png"]],
      "attribution": null}},
   {"name": "D square nv",
    "permalink": "d-square-nv",
    "crunchbase_url": "http://www.crunchbase.com/company/d-square-nv",
    "namespace": "company",
    "overview": "D square assists plant management in the process industry to detect, analyze and solve\r\ncritical bottlenecks to reach and surpass even the most challenging production targets, through the combination of high-end business consultancy services and innovative and market leading data mining know-how, packaged as real-time software products enabling custom support and interaction for each operational role.\r\n\r\nD square embeds state-of-the-art data mining and statistical learning techniques into software appliances and tailored solutions for process performance optimization. The research and development roadmap is driven by a combination of domain knowledge and experience, partner contacts and service projects that act as a probe in the market. The company's strong research backbone includes research initiatives on plant monitoring that are funded by IWT Vlaanderen.\r\n\r\nD square is a spin-o company of K.U.Leuven and won in 2009 the award of \"best spin-o of the year\". It is currently developing a software suite to improve overall plant eciency and increase the current plant safety level.",
    "image":
     {"available_sizes":
       [[[130,
          150],
         "assets/images/resized/0011/0089/110089v2-max-150x150.jpg"],
        [[218,
          250],
         "assets/images/resized/0011/0089/110089v2-max-250x250.jpg"],
        [[344,
          394],
         "assets/images/resized/0011/0089/110089v2-max-450x450.jpg"]],
      "attribution": null}},
   {"name": "Square",
    "permalink": "square",
    "crunchbase_url": "http://www.crunchbase.com/company/square",
    "namespace": "company",
    "overview": "Square is a revolutionary service that enables anyone to accept credit cards anywhere. Square offers an easy to use, free credit card reader that plugs into a phone or iPad. It's simple to sign up. There is no extra equipment, complicated contracts, monthly fees or merchant account required.\r\n\r\nCo-founded by Jim McKelvey and Jack Dorsey in 2009, the company is headquartered in San Francisco with additional offices in Saint Louis and New York City.\r\n",
    "image":
     {"available_sizes":
       [[[130,
          34],
         "assets/images/resized/0006/8147/68147v15-max-150x150.png"],
        [[130,
          34],
         "assets/images/resized/0006/8147/68147v15-max-250x250.png"],
        [[130,
          34],
         "assets/images/resized/0006/8147/68147v15-max-450x450.png"]],
      "attribution": null}},
   {"name": "Genetics Squared",
    "permalink": "genetics-squared",
    "crunchbase_url": "http://www.crunchbase.com/company/genetics-squared",
    "namespace": "company",
    "overview": "Genetics Squared, Inc. provides solutions for personalized medicines in Michigan. The company focuses on offering life sciences solutions. Its Evolver technology, a machine learning technique that produces mathematical models that describe a dataset based on what specific questions are being asked about that dataset. The company\u2019s technology is applied in various areas of clinical and preclinical biomedical research, such as for clinical oncology, infectious disease, nephrology, and autoimmune disease. Genetics Squared, Inc. was founded in 2001 and is based in Ann Arbor, Michigan.\r\n",
    "image":
     {"available_sizes":
       [[[150,
          41],
         "assets/images/resized/0011/9606/119606v1-max-150x150.jpg"],
        [[250,
          69],
         "assets/images/resized/0011/9606/119606v1-max-250x250.jpg"],
        [[386,
          108],
         "assets/images/resized/0011/9606/119606v1-max-450x450.jpg"]],
      "attribution": null}},
   {"name": "Pay It Square, LLC",
    "permalink": "payitsquare-llc",
    "crunchbase_url": "http://www.crunchbase.com/company/payitsquare-llc",
    "namespace": "company",
    "overview": "Pay It Square helps people collect money from groups of friends.\r\n\r\nIt is ideal for:\r\n\r\n- Organizing a bachelor or bachelorette party.\r\n- Team managers who need to collect league dues.\r\n- Organizers collecting for group outings.\r\n- Collecting rent from roommates.\r\n- Buying a gift on behalf of a group.\r\n- Buying tickets to an event for a group of people.\r\n- Organizing a group vacation.\r\n- Collecting association dues.\r\n\r\nYou get the idea. People are constantly collecting these types of payments.  Pay It Square makes it easier.",
    "image":
     {"available_sizes":
       [[[150,
          26],
         "assets/images/resized/0005/7770/57770v2-max-150x150.jpg"],
        [[156,
          28],
         "assets/images/resized/0005/7770/57770v2-max-250x250.jpg"],
        [[156,
          28],
         "assets/images/resized/0005/7770/57770v2-max-450x450.jpg"]],
      "attribution": null}},
   {"name": "Kee Square",
    "permalink": "kee-square",
    "crunchbase_url": "http://www.crunchbase.com/company/kee-square",
    "namespace": "company",
    "overview": "Kee Square S.r.l., a spin-off company of the Politecnico di Milano, develops innovative techniques in video and audio signal processing for biometric identification and tracking, detection of hazardous events, and security applications in general.\r\n\r\nKee Square products are designed and customized to fulfill the Law Enforcement and Commercial Markets requirements. ",
    "image":
     {"available_sizes":
       [[[150,
          76],
         "assets/images/resized/0007/0993/70993v1-max-150x150.jpg"],
        [[250,
          126],
         "assets/images/resized/0007/0993/70993v1-max-250x250.jpg"],
        [[298,
          151],
         "assets/images/resized/0007/0993/70993v1-max-450x450.jpg"]],
      "attribution": null}},
   {"name": "Colton Square Business Park",
    "permalink": "colton-square-business-park",
    "crunchbase_url": "http://www.crunchbase.com/company/colton-square-business-park",
    "namespace": "company",
    "overview": "Where the city\u2019s past and future dovetail Colton Square is the cornerstone of Leicester\u2019s dramatic Business Quarter renaissance.\r\n\r\nThis unique development represents the fusion of the listed former police station on Charles Street with striking high profile contemporary office space. The result is breathtaking in its vision.\r\n\r\nNow complete and ready for occupation One and Two Colton Square provide corporates and professionals with the cachet of locating in the city\u2019s most prestigious and dramatic commercial address. No other business space in Leicester makes such a bold statement.",
    "image":
     {"available_sizes":
       [[[81,
          71],
         "assets/images/resized/0010/3576/103576v2-max-150x150.png"],
        [[81,
          71],
         "assets/images/resized/0010/3576/103576v2-max-250x250.png"],
        [[81,
          71],
         "assets/images/resized/0010/3576/103576v2-max-450x450.png"]],
      "attribution": null}},
   {"name": "SDP Squared, LLC",
    "permalink": "sdp-squared-llc",
    "crunchbase_url": "http://www.crunchbase.com/company/sdp-squared-llc",
    "namespace": "company",
    "overview": "SDP Squared was founded to help small businesses in the Maryland, Metro Baltimore and Southern New Jersey areas get the most out of their business technology. They provide affordable IT support services especially taylored for non-profits and small business companies.",
    "image":
     {"available_sizes":
       [[[137,
          76],
         "assets/images/resized/0006/8027/68027v2-max-150x150.jpg"],
        [[137,
          76],
         "assets/images/resized/0006/8027/68027v2-max-250x250.jpg"],
        [[137,
          76],
         "assets/images/resized/0006/8027/68027v2-max-450x450.jpg"]],
      "attribution": null}},
   {"name": "PE Squared",
    "permalink": "pe-squared",
    "crunchbase_url": "http://www.crunchbase.com/company/pe-squared",
    "namespace": "company",
    "overview": "PE SQUARED is a North Carolina Civil Engineering Firm licensed in North and South Carolina specializing in Land development services. We have a focus on sustainable site development practices that can be both economical and sustain the environment into the future. Additionally our services include floodplain studies, preliminary site analysis, cost estimating, and project management.",
    "image":
     {"available_sizes":
       [[[103,
          150],
         "assets/images/resized/0008/0163/80163v2-max-150x150.jpg"],
        [[103,
          150],
         "assets/images/resized/0008/0163/80163v2-max-250x250.jpg"],
        [[103,
          150],
         "assets/images/resized/0008/0163/80163v2-max-450x450.jpg"]],
      "attribution": null}},
   {"name": "Jackson Square Group",
    "permalink": "jackson-square-group",
    "crunchbase_url": "http://www.crunchbase.com/company/jackson-square-group",
    "namespace": "company",
    "overview": "Jackson Square Group is a market research technology firm. Based in New Orleans, the firm creates technologies that maximize the efficiency and effectiveness of gathering data and intelligence from consumer markets.",
    "image":
     {"available_sizes":
       [[[150,
          150],
         "assets/images/resized/0009/9935/99935v2-max-150x150.png"],
        [[250,
          250],
         "assets/images/resized/0009/9935/99935v2-max-250x250.png"],
        [[300,
          300],
         "assets/images/resized/0009/9935/99935v2-max-450x450.png"]],
      "attribution": null}}]}

16:47:53.321 (321102000)|FATAL_ERROR|System.JSONException: Illegal unquoted character ((CTRL-CHAR, code 11)): has to be escaped using backslash to be included in string value at input location [26,924]

 

16:47:53.098 (98603000)|CALLOUT_REQUEST|[130]|System.HttpRequest[Endpoint=http://api.crunchbase.com/v/1/search.js?query=square, Method=GET]

16:47:53.098 (98603000)|CALLOUT_REQUEST|[130]|System.HttpRequest[Endpoint=http://api.crunchbase.com/v/1/search.js?query=square, Method=GET]

Hi,

I want to get all field names and object names in my Org.I am using "getGlobalDescribe" and "fields.getMap" in my apex code.but with this code i can access only upto 100 objects,if i am trying to access more than 100 objects it is throwing me error.

 

Kindly let me know is there any work around for this.

 

Thanks,

Hey All,

 

I don't know if this is an actual problem or i'm just missing something really obvious. Anyways the issue I'm having is when I insert an object during a test method, If I query for that newly inserted object in the actual testMethod it returns the object. However, If I insert an object, then call a method that query's for that object it returns no results. It is kind of confusing to explain so I put some example code below. Any help would be greatly appreciated.

static testMethod void testCampMon() {     
        Client_ID__c newClient = new Client_ID__c(
                                                    Name = 'Test Client',
                                                    Client_ID__c = 'XXXXXXXXXXXXXXXXXXXXXXXX');
        insert newClient;     
        Test.startTest();
        
        // This will return the object
	Client_ID__c c = [select Name, Client_ID__c, Id from Client_ID__c limit 1];
	System.debug('C ID = ' + c.Id);
        
        // This just calls the same query above (without the limit)
        // However no records are returned
        Client_ID__c client2 = CampaignMonitorService.getClientIds()[0];
Test.stopTest();
    }

// Example getClientIds() method
public static List<Client_ID__c> getClientIds() {
        return [select Name, Client_ID__c, Id from Client_ID__c];

    }

 

  • October 28, 2011
  • Like
  • 0

Hello,

 

I create a apex class, which contains some dynamic SOQL. The function is similar as searching product in price book.

 

All of them works fine. But I tried the security check in my account and found dynamic SOQL caused security warning.



Security check link: http://security.force.com/sourcescanner

My SOQL:

public with sharing class GroupOperationController{
    public String Keyword {get; set;}
    public String FieldName {get; set;}
    public String Operator {get; set;}
    public String FieldValue {get; set;}
     
    private String getQuerySql() { 
        String fields = ' Id, Name, PCOL__Account__r.Id, PCOL__Account__r.Name, PCOL__modelS__c, PCOL__manufacturerS__c, PCOL__serialNumberS__c ';
        String strSql = 'select '+fields+' from PCOL__Device__c where Name != null ';
         
        strSql += getKeywordWhere();
        strSql += getMatchFiltersWhere();
        System.debug('xxxxxxxxxxxx ' + strSql + ' xxxxxxxxxxxxxxx');
        return strSql;
    }
    private String getKeywordWhere(){
        String sqlWhere = '';
        if(Keyword != null && !Keyword.equals('')){
            sqlWhere = ' and (';
            Integer i = 0;
            for(SelectOption so: FieldNames){
                if(i > 1){
                    sqlWhere += ' or ';
                }
                if(i > 0){
                    sqlWhere += ' ' + so.getValue() + ' like \'%' + Keyword + '%\' ';
                }
                i++;
            } 
            sqlWhere += ') '; 
        }   
        return sqlWhere;
    }
    private String getMatchFiltersWhere() { 
        String sqlWhere = '';
        if(FieldName != '' && Operator != '' && FieldValue != '' ) { // have a filter
            if(Operator == 'e'){
                sqlWhere += ' and ' + FieldName + ' = \'' + FieldValue + '\' '; 
            }else if(Operator == 'n'){
                sqlWhere += ' and ' + FieldName + ' != \'' + FieldValue + '\' '; 
            }else if(Operator == 's'){
                sqlWhere += ' and ' + FieldName + ' like \'' + FieldValue +  '%\' '; 
            }else if(Operator == 'c'){
                sqlWhere += ' and ' + FieldName + ' like \'%' + FieldValue + '%\' '; 
            }else if(Operator == 'z'){
                sqlWhere += ' and ' + FieldName + ' like \'%' + FieldValue + ' '; 
            }        
        } 
    } 
    private void BindObjList(){
        ObjList = new List<GroupOperationDevice>();
        for(PCOL__Device__c d: Database.query(getQuerySql())){  
                ObjList.add(new GroupOperationDevice(d, false, visible)); 
        } 
    }
    public PageReference submit(){
        BindObjList();
        return null;    
    }
}

 After security checking, some warning appearred. It said all the code like "sqlWhere +=" are not security.

 

Any one can help me how to use dynamic SOQL and support security check?

  • October 28, 2011
  • Like
  • 0

Hi,

 

I have a scheduled job which is batch apex that call external web service.. My case is I want to call external web service 10 times per batch execution where schedule run.. Example, 11 o'clock -> run batch which calling external web service 10 times, 12 o'clock -> same process and so on... Is this possible? I have done that and the result is the first batch run successfully calling web service 10 times, second batch run -> I got exception -> First error: Too many callouts: 2, third, and so on has the same error message...

For the information, I wan to call the web service to get the values returned and updated to Salesforce.com records..

Any suggestions would be great...

Thanks...

Hi experts:

 

For regular picklist (which is not a multiselect picklist),  'like' or 'includes' is not valid in the SOQL query.  So how to implement the similar feature to query the picklist field in a SOQL ?

I would like to convert the amount from USD to local currency if the opportunity stage is closed won.

 

The following website which I would like to connect with, http://www.webservicex.net/CurrencyConvertor.asmx?op=ConversionRate, how can I connect to the website.

 

I am quite new for developer. Here is the code when I tried:

 

trigger CurrencyConversion on Opportunity (after update) {
    if(opp.StageName == 'Closed Won')
    {
       
    }
}

 

Thanks,

Tony

We have an existing class that uses the Test.isRunningTest() method.  Today we tried making changes to that class (completely unrelated to the isRunningTestMethod) and weren't able to save it because of a "method doesn't exist or incorrect signature" error on that method.  Did something change with the Winter 12 release where we can no longer use this in code?  If so, is there something replacing this functionality?  If we should still be able to use it, any thoughts on why we are receiving this error now?


Save error: Method does not exist or incorrect signature: Test.isRunningTest()


  • October 27, 2011
  • Like
  • 1

Hey,

 

When I use System.Schedule() to schedule an Apex job, I am experiencing some strange behavior:

 

* The job does show up on the 'Scheduled Jobs' page on the org, but its 'Manage' link is missing (the only link beside the job entry is 'Del').

 

* According to the 'Scheduled Jobs' page, the job does run at the scheduled time, but there is no evidence anywhere else in the org that the job actually run.  No debug logs appear and none of the side-effects of the job appear on the org.  I even stubbed out the class' execute() method with a System.assert ( False ) statement, to make it throw out an error email, but that doesn't happen either.  It definitely seems like nothing at all is being executed.

 

When I schedule the job via the UI (Develop -> Apex Classes -> Schedule Apex), it runs fine as expected.

 

Why is this?

 

(and why oh why is the page behind the 'Manage' link read-only??)

 

Thanks

  • October 27, 2011
  • Like
  • 2

Taking over SFDC for a company who had a text field on the quote called "product quick add" which when a product code is entered, will automatically create the quote line items based on the ';' separated values in the product quick add field. 

 

The issue is that these are being orded alphanumerically based on the product record IDs and not the order they were entered by the user. 

 

Short of changing all the code and forcing the user to set an order, is there any way change the order in which records are inserted from a map? 

 

-Justin 

I need to get the actual Parent ID from the Account object while querying a custom child object.  

 

I have an existing soql that looks like this...

 

// Build IDNumber list

Map<String,ID_Number__c> IDNumbers = new Map<String,ID_Number__c> (

    [select ID__c, Parent_Rate__c ),

    from ID_Number__c

    Where ID__c IN :idsToQuery] );

 

 

 

When I try this - I get an "enexpected token; 'from' error...

 

Map<String,ID_Number__c> IDNumbers = new Map<String,ID_Number__c> (

    [select ID__c, Parent_Rate__c ), (Select Parent, from Account),

    from ID_Number__c

    Where ID__c IN :idsToQuery] );

 

Any guidance?

 

Thanks!

From what I can find out so far, the only way to give a user permission to Schedule Apex is to provide the user's profile with permission to "Author Apex." Unfortunately, doing this requires that the profile also have the ability to Modify All Data, which I really do not want to do. We use FinancialForce, and we try to keep a lot of that locked down.

 

The reason I want the specific user to schedule the apex job (other than because I do not want to do it) is that the message sent when the batch job completes goes to whoever scheduled the job.

 

So, is there a way to provide a profile (or permission set) so that a user can Schedule Apex but not have to actually Author Apex?

 

Also, why does the Schedule Apex button appear if the user cannot use it?

Hello, i have a small problem...

I want to update a list like this, but it doesnt work.

 

                List<obj__c> list = [SELECT Value__c,Masterobj__r.otherValue__c FROM obj__c ];

                for(obj__c i : list){
                        i.Value__c = true;

                        i.Master__r.otherValue__c = true;

 

                }    
                update list;

 

Value__c becomes true but not    Master__r.otherValue__c. Where is my mistake?

Customer wants that when a user goes to grant access to another user via Manual Sharing, they should not have option to share with Roles and Roles-Subordinates. The users should only be able to share with another users. 


I know from the standard out-of-box Salesforce Page for Sharing, we cannot remove these options from the left-hand side palette.


However, can we have some customized APEX trigger or some sort of validation which will not allow users to share their records with Roles/Roles and Subordinates?


Please advise.



Thanks,


Vimal

Hi,

 

i have a class that i run from system log screen ervery month. it was working fine but all of a suddon it has started giving errors as below.

 

 

*********************************** Error Log******************************

 

Apex script unhandled exception by user/organization: 00520000001grzo/00D20000000BaRL

 

Failed to process batch for class 'clsInvoiceRun' for job id '7072000000AspWh'

 

caused by: System.DmlException: Insert failed. First exception on row 12; first error: INVALID_CROSS_REFERENCE_KEY, Owner ID: owner cannot be blank: [OwnerId]

 

Class.clsInvoiceRun.execute: line 180, column 9

External entry point

 

Debug Log:

6 (476287000)|SYSTEM_METHOD_ENTRY|[163]|MAP.containsKey(ANY)

14:53:05.476 (476365000)|SYSTEM_METHOD_EXIT|[163]|MAP.containsKey(ANY)

14:53:05.476 (476400000)|STATEMENT_EXECUTE|[163]

14:53:05.476 (476458000)|VARIABLE_ASSIGNMENT|[161]|i|103

14:53:05.476 

.

.

.long list continue.....

.

.

14:53:05.818 (818405000)|WF_RULE_FILTER|[Invoice : Invoice Status equals Finance Approved]

AND [Invoice : Record Type equals Invoice Stage 2]

14:53:05.818 (818527000)|WF_RULE_EVAL_VALUE|1

14:53:05.818 (818595000)|WF_CRITERIA_END|false

14:53:05.818 (818681000)|WF_SPOOL_ACTION_BEGIN|Workflow

14:53:05.818 (818828000)|WF_ACTION| None

14:53:05.818 (818897000)|WF_RULE_EVAL_BEGIN|Escalation

14:53:05.818 (818960000)|WF_RULE_EVAL_END

14:53:05.819 (819194000)|WF_ACTIONS_END| None

14:53:05.819 (819278000)|CODE_UNIT_FINISHED|Workflow:01I20000000cVKI

14:53:05.820 (820086000)|DML_END|[180]



 

any help will be appriciated

 

thanks,

 

 

Hi,

 

I have added a new number field in Account object. I want to set a default value 0 to this field. How is it possible? Please help.

 

Thanks and Regards

Hari G S

 

Hi,

 

I have done some triggers in my sandbox isntance; when i tried to deploy these triggers from Sandbox to Production, I got the error that the Api version in my Production Org is 22.0, this is because my sandbox is on Winter 12 and Production is still in Summer 11,  this will be solved this weekend

:))

 

My question is......I have tried also to do it with Eclipse, and it saids that my version is 20.0

 

How can up upgrade to 23.0?

Thanks!!!

  • October 11, 2011
  • Like
  • 0

Does anyone know if there is a new release coming up for IDE? Are there alternatives for force.com ide? 

  • September 28, 2011
  • Like
  • 0