• Shamil
  • SMARTIE
  • 595 Points
  • Member since 2008

  • Chatter
    Feed
  • 21
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 45
    Questions
  • 129
    Replies

With Winter '13 batch apex can call another batch apex (or itself) from the finish() method. E.g.

 

global void finish(Database.BatchableContext BC){
  Database.executeBatch(new MyBatch());
}

I'm noticing that in this scenario (i.e. when a batch keeps running itself again) I get 2 records in the AsyncApexJob table/object for the same MyBatch apex class: 1 record with status 'Processing' and the 2d with status 'Queued'.

 

Questions:

1. Is this expected? Shouldn't the first execution of the batch completely stop before the second one gets queued?

2. If above is the expected behavior, at the point of time when there are 2 records - I assume they count  against the limit of having 5 active/queued batch jobs - true?

 

Thanks!

Is it possible to create custom buttons that aren't page specific? The button doesn't interact with Salesforce, it only invokes a third-party applicaiton. I know I can create Custom buttons, but I'd need to go to each page I want to add it to and create the custom button, then add it to each page layout. I'd prefer to only create the buttons once.

Thanks

Jerri

Hi !

 

I'm trying to query a KnowledgeArticleVersion record and its associated KnowledgeArticle in a single SOQL query.

 

However, reading the objects description, it seems that the KnowledgeArticleVersion's KnowledgeArticleId reference field does not have a RelationshipName.

That means that I cannot do

 

select KnowledgeArticle.CaseAssociateCount from KnowledgeArticleVersion where id='something'

I cannot do that because "KnowledgeArticle" is not a valid relationship on a KnowledgeArticleVersion.

 

Is there a reason for this ? Is there a workaround ?

 

Thanks.

I am new to force.com and apex and am coding up a batch class to copy records from the Opportunity object into a custom object.

Everything is working well except I can't figure out how to access fields in a relationship to Opportunity such as Account.Name.

 

For example, I am using a query such as this in my batch class start method:

 

    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator('SELECT o.Amount, o.Account.Name from Opportunity o');
    }

 

Then in my execute method, I am accessing the values like this:

 

    global void execute(Database.BatchableContext BC, list<sObject> scope){
        List<OpportunityTrend__c> opps = new List<OpportunityTrend__c>();

        for (sObject s : scope) {

            OpportunityTrend__c OpTrend = new OpportunityTrend__c();

            OpTrend.Amount__c = (Decimal)s.get('Amount');

            opps.add(OpTrend);

        }

        insert opps;

    }

 

Where I need help is in the syntax to get at the o.Account.Name field string value.

I've tried this, but it doesn't work:

 

        OpTrend.AccountName__c = (String)s.get('Account.Name');

 

I'm not sure if my problem is in my s.get() call (wrong syntax, wrong method, etc) or if it's in my initial SOQL query.

 

 

Any help would be greatly appreciated.

BTW, I have looked at this thread: SOQL-Getting-Opportunity-AccountName-in-one-query which appears to be very similar to the question I have, but does not provide the level of detail I need.

 

Thanks!!

 

-mike

 

I'm struggling a little to find the necessary documentation to get started using the Authenticated Website profile & user licenses type.  How do I create new users?  Is the only way to do that is to create the user using Apex?  We don't need (or want) self-registeration in our use case -- we really want the bare minimum "user get username and password & is able to login..."

 

Ideally this is probably just a simple recipe and I'd be ready to go -- but I'm struggling figuring that out, even though I think it should be easy over all.

 

Michael

I am trying to use apex:actionFunction that has one parameter in my apex:page javascript but the parameter is always null and I cannot figure out WHY?

 

I created a simple test page to test what I am doing:

--------------------------------------------------------------------------

<apex:page standardController="Quote" extensions="QuoteLineItems_ControllerExtension">

<apex:pagemessages />
<apex:pageBlock mode="edit">
    <apex:form id="testPage_Form">
        <script language="JavaScript" type="text/javascript">  
            function test1() {
                alert('>> init TEST_PAGE <<');   
                updateTest('this is my test data');
            }
        </script>
        
        <apex:actionFunction name="updateTest" action="{!updateTestData}">
           <apex:param name="test_param1" value="TEST_DUMMY" />
        </apex:actionFunction>
        
        <input type='button' value='TEST 1' onclick='test1();'/>
    </apex:form>
</apex:pageBlock>
</apex:page>

 

Here is a method in my the controller:

--------------------------------------------------

    public PageReference updateTestData() {
        System.Debug('>>> updateTest <<<');
        String test_param1 = ApexPages.CurrentPage().getParameters().get('test_param1');
        System.Debug('>>> test_param1 = '+ test_param1 + ' <<<');
        return null;
    }

 

Debug Log returns:

    >>> updateTest <<<

    >>> test_param1 = null <<<         ?? WHY NULL, expecting 'this is my test data'

 

WHAT am I doing wrong?

Hi,

 

I am having some trouble writing unit test for my apex class. I keep getting the error:System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Member__c]: [Member__c]. 

 

Here is my code: 

 

public class exNewFeedback {

    public Case requests {get; set;}
    public String details {get; set;}
    public String fbFrom {get; set;}
    public String fbSource {get; set;}
  
    
    public exNewFeedback(ApexPages.StandardController controller) {
        this.requests = (Case)controller.getRecord();
        this.requests = [SELECT ID, accountID, Supplier__c, User_Owner_Office__c FROM Case WHERE ID =: requests.ID][0];
    }
           
    public PageReference createRequest(){
        Feedback__c compliment = new Feedback__c();
        compliment.Member__c = requests.accountID;
        compliment.Request__c = requests.ID;
        compliment.Supplier__c = requests.Supplier__c;
        compliment.Escalated_to_Complaint__c = 'No';
        compliment.Relevant_office__c = requests.User_Owner_Office__c;
        compliment.Details__c = details;
        compliment.Feedback_From__c = fbFrom;
        compliment.Feedback_Source__c=fbSource;
        insert compliment;
     
        PageReference fbPage = new ApexPages.StandardController(compliment).view();
        fbPage.setRedirect(true);
        return fbPage;
    }
    
    static testMethod void testNewFeedback(){
           Account member = new Account(Name = 'Test User');
           insert member;
           LIST<Account> memberlist = [SELECT ID FROM Account LIMIT 1];
           System.assertEquals(1, memberlist.size());
           Contact c = new Contact(FirstName = 'Test', LastName='Test', Account = member, Region__c='Africa', 
                                   Newsletter_Preferences_taken_setup__c = 'Yes', Where_did_client_hear_of_us__c = 'Do Not Know',
                                   Membership_Status__c = 'N/a - Corporate Bus Dev Contact');
           insert c;
           List<Contact> clist = [SELECT ID FROM CONTACT LIMIT 1];
           System.AssertEquals(1, clist.size());
           Case request = new Case(Contact = c, Origin = 'Email', Status = 'Open');
           insert request;
           List<Case> requestlist = [SELECT ID FROM CASE LIMIT 1];
           System.AssertEquals(1, requestlist.size());
           Case requests = [SELECT ID, accountID, Supplier__c, User_Owner_Office__c FROM CASE WHERE 
                            ID =: request.ID];
           Apexpages.Standardcontroller stdCon = new apexpages.Standardcontroller(requests);
           exNewFeedback exFB = new exNewFeedback (stdCon);
           exFB.createRequest();   
    }
}

 Please let me know where I went wrong. Thank you. 

Hi all,

 

I have created a report out 3000 leads I have 770 leads with Date of Birth. I want to convert only this 770 leads to contacts.

 

Can anyone please help me with this?

 

Thanks in Advance

 

Cheers

Uma

Should I create a trigger for opportunity for update or use a workflow rule on opportunity?   Which is better and why?

 

 

 

 

Hi!

 

The the same query that works in the workbench fails running in Salesforce:

 

System.QueryException: unexpected token: FIND

 

Any help is appreciated!

 

Thanks!

Laura

 

The object eci_HTTPEventLog__c contains the following:

eci_HTTPEventLog__c.response__c = '<Envelope><Body><RESULT><SUCCESS>true</SUCCESS<SESSIONID>349557C0E497DDFC154379B4DF528057</SESSIONID><ORGANIZATION_ID>5872ae98-1341ac53619-d7c8ec57ae636c7258d3eb0ef0e531f2</ORGANIZATION_ID<SESSION_ENCODING>;jsessionid=349557C0E497DDFC154379B4DF528057</SESSION_ENCODING</RESULT></Body></Envelope>';

 

 

            String response = '';

            

            String queryString = 'FIND {jsessionid} IN ALL FIELDS RETURNING eci_HTTPEventLog__c';  // fails here

            

            for (LIST<SObject> sobj : database.query(queryString)) {

              for (SObject objs : sobj) {

                  

                if (objs.getSObjectType() == eci_HTTPEventLog__c.sObjectType)

                {

                  eci_HTTPEventLog__c event = (eci_HTTPEventLog__c) objs;

                  response = event.response__c;

                }

              }

            }

What is data loader ?What is the use of data loader?Where to use it?

Hey all

 

I'm try to build an interface that is dual purpose record viewer / editor. I'm running into the problem of not being able to go to the next page if some records aren't passing validation (though they are not edited). The data pre-dates the validation rules, so when you view them, you can't move to the next page.

 

Does the setcontroller automatically try to save records when you call next() ?

Hi all,

I want to display Contact History as a related list in Visual force page. I am trying below syntax

<apex:page standardController="Contact">
        <apex:relatedList list="Histories"/>
</apex:page>

But it is giving error as 'Histories' is not a valid child relationship name for entity Contact'

Please let me know the correct syntax of API name for Contact history to display it as a related list.

 

Thanks

Hi,

 

I have a requirement is that

 

I have a field name as 'Job Name' where i filles engineer in one record now if user again creating the record where job name is engineer then its should show error massage that one record with same job name is allready exist.

 

So any idea how i can write a trigger for this.

 

Thanks in Advance:))))

 

This is just some example code, I don't want the focus of what I'm doing to cloud the concept I'm trying to figure out.

 

code:

 

sobject[] something = [SELECT Contact.FirstName, Contact.Account.Name, contact.account.type from Contact];

 

I've used sobject[] here instead of contact[] because in my project the query is dynamic and could be from a different table.

 

My question is, how do I get the relationship field from this? Normally, I know you can do this:

 

string theName = something[0].Account.Name;

 

However, this results in the error: Field expression not allowed for generic SObject

 

How do I get around this?

Public boolean var1{get;set;}

 

In the Controller constructor

 

var1 =ApexPages.CurrentPages.getParameters.get('var1');

 

 

if i declare like this for a boolean parameter it is giving error.

where as for string it is fine.

 

Do any body suggest me how to declare one in the controller

 

Hi all does anyone know how i can convert this select to a map:

 

for(Recurring_Service_Invoice__crsi : ClonedInvoices)

{

   for(Recurring_Service_Line_Item__ccli : [SelectUnit_Price__c, Unit_Cost__c, Start_Date__c Service__cRecurring_Service_Line_Item_ID__c, Recurring_Service_Invoice__c, Quantity__c, Notes__c, Next_Invoice_Due_Date__c, Name, Monthly_Charging_Metric__c, Invoice_Total__c, Invoice_Cost__c, Initial_Quantity__c, Id, End_Date__c, Customer_PO_Number__c, Category__c, Billing_Period__c, Asset__cFrom Recurring_Service_Line_Item__c where Recurring_Service_Invoice__c = :rsi.OldInvoiceId__c])

 

I need to replace this with a map so im not doing loads of soql calls but im stumped how to do it. 

 

Thanks

I just want to check, global with sharing class enforces same user level permission as public with sharing class ?

 

Thanks

Ram

 

<apex:page standardController="Opportunity" recordSetVar="opportunities" tabStyle="Opportunity" sidebar="false">
<apex:pageBlock >
      <apex:repeat value="{!opportunities}" var="opp"> 
         <apex:outputPanel rendered="{!IF(opp.Status__c == 'Subscriber',true,false)}" >
        {!opp.Name},
        </apex:outputPanel>
       </apex:repeat>
       </apex:pageBlock>
</apex:page>

I have created the above code; however, I have noticed that this is only reviewing the top maybe 20 results from the full opportunities list. Does anyone have any ideas on why this would be happening? If it doesn't evaluate the entire list, then I don't get the results that I want.