• Shamil
  • SMARTIE
  • 595 Points
  • Member since 2008

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

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

 

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. 

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;

                }

              }

            }

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() ?

 

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?

  • April 29, 2012
  • Like
  • 1

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

 

Thanks

Ram

 

  • April 26, 2012
  • Like
  • 0

We want to be able to log an object for historical purposes but it's way too much data to do that through salesforce so I figured we could dump the data into a CSV file. I want to be able to dump the CSV file itself directly to the attachments object if that's possible. 

The way I'm currently generating the CSV file is by using the following in my visualforce page...

<apex:page standardController="Facility_Carrier_Contract__c" extensions="mc_FCCCodeHistory" id="page" standardStylesheets="false" showHeader="false" sidebar="false" contenttype="application/x-excel#export.csv">
{!exportData}</apex:page>

 

 

Hello, I am new to APEX and in programming in general, so apologies for asking these basic questions.

 

I am trying to create a trigger that evaluates the prior value of the case owner field and if it changed from a queue to a user, update a lookup field (to users) with the new owner, so far I have been unabled to do it and I workarounded this creating a workflow rule that does this evaluation and changes a checkbox to true, I then created a very simple trigger that updates the lookup field if the checkbox is selected(true) , obviously this is not ideal as I would like to create all the functionality in the trigger.

 

Can someone please provide some guidance in how can all this  be achieved in the trigger . How can I say if the priorowner was a queue (or a list of queues) and the new owner is a user, update the lookup field with the new owner.

 

Many thanks in advance for any help on this.

<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.

 

We are trying to create a managed package and host it on the appexchange. Our implementation includes standard objects like Leads, Contacts, Events and Campaign. Our concern at this point is the following

  1. We are creating records in these objects. WHat is the recommended approach to consider the required fields or other constraints the customers or subscribers may have for these objects? We are not aware of these constraints/required field and our record inserts may fail. Is this even recommended to use standard objects given this problem?
  2. In test classes to test the solution, we need to create instance of these objects to create data. Will these test classes fail in the subscriber's org because of missing required fields or validation rules/constraints.

Please help and advise the recommended approach. Thanks in advance for your help.

Hi,

 

I've a baisc question on Integration and web services part.

 

1) We are integrating oracle with salesforce through web services. what i would like to know is,

      - If i provide the enterprise WSDL to oracle, can it login to salesforce (yes, i know this part) and create an account, contact and a case? ( should some one write the logic in oracle side to do this?)

      - Do i need to write a web service in Salesforce to create an account, contact and case, then send a response back to oracle? I thought i should write a web serivce, but some salesforce consulting expert told me that these actions are possible if i give the oracle team just the standard enterprise WSDL rather me writing a web service to do these actions.

 

Please confirm.

 

Thanks.

 

 

  • April 18, 2012
  • Like
  • 0

Hi,

 

I am trying to insert test data as shown below: (but I am getting error message "System.DmlException: Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []")

 

CODE:

--------

  public static List<PriceBookEntry> pbentries(Integer quantity) {
     
     List <PriceBook2> pb2list = new List<PriceBook2>();
     List <Product2> prodlist = new List<Product2>();
     List <PriceBookEntry> pbelist = new List<PriceBookEntry>();
     
     for (Integer j = 0; j<quantity; j++){
       pb2list.add(new PriceBook2(Name = 'Test Price Book' +j, isActive = true));
     }
     insert pb2list;
     
     for (Integer j = 0; j < quantity; j++) {
       prodlist.add(new Product2(Name = 'Test Product' +j, productCode = 'ABC', isActive = true));
     }
     insert prodlist;
     
     for (Integer j = 0; j < quantity; j++) {
       pbelist.add(new PriceBookEntry(Pricebook2Id=pb2list.get(j).id, Product2Id=prodlist.get(j).id, UnitPrice=99, isActive=true, UseStandardPrice=false));
     }
     
     insert pbelist;
     
     return pbelist;
  }

 

Please help me how to resolve this issue.

 

Thanks,

JBabu  


  • April 10, 2012
  • Like
  • 0

HI,

 

I am creating a clone button that when clicked, fills in specified set of fields. i am trying to get it to fill a lookup with the link to the master record that it has been cloned from.

 

this is what i have at the moment, so the parent case field is getting populated with the ID. How can i get it populated with the correct link? I am not sure what code i should add to the before or after the case.id bit 

 

/{!Case.Id}/e?retURL=%2F{!Case.Id}&clone=1&cas6={!Case.Reason}&cas14={!Case.Subject}&cas15=Reopen%20of%20Case%20{!Case.Link}%0D{!Case.Description}&cas16=Reopen%20of%20Case%20{!Case.CaseNumber}
&00NW0000000TDWx={!NOW()}
&00NW0000000TDXC=
&00NW0000000TDSc=
&00NW0000000TDbx=
&cas28={!Case.Id}

 

Hi,

 

I am trying to create a trigger that creates mutilple junction object records. I keep getting the following error: Compile Error: unexpected token: 'startDate' at line 6 column 100. Here is my code: 

trigger testCreateHoliday on Leave_Request__c (after update) {
    Leave_Request__c insertLR = new Leave_Request__c();
    Date startDate = insertLR.Request_Start_Date__c;
    Date endDate = insertLR.Request_End_Date__c;
    
    List<Holiday__c> allHoliday=[SELECT ID FROM Holiday__c Where Holiday__c.Holiday_Start_Date__c > startDate];
    insertLR = trigger.new[0];
    List<LR_and_Holiday__c> lrholidaylist = new List<LR_and_Holiday__c>();
    Integer x = 0;
    for (integer i = 0; i<=1; i++){
        LR_and_Holiday__c lrholiday = new LR_and_Holiday__c();
        lrholiday.Leave_Request__c = insertLR.ID;
        lrholiday.Holiday__c = allholiday[x].ID;
        lrholidaylist.add(lrholiday);
        x++;
    }
    Database.insert(lrholidaylist);
}

 Please help. Thank you.

Hi, please respond if any one came across this functionality,

 

we happened to disable, enable the create pdf button on the quote based on a status field. How to proceed with this.

 

I found 2 option to override the standard with a visual force page or using a custom button.

 

In both the case i ran out of option on to fins the quote template id and use it in the creation of the pdf. 

 

Any ideas on this

  • April 05, 2012
  • Like
  • 0

Hi,


I have been working on something all day where an outputPanel gets rendered on a page after a user does a search.
For some reason and I cannot work out why, a hidden outputPanel does not render after a user clicks on a commandButton.

 

Below is my code. I have taken things out which are not neccessary

 

Any help would be appreciated.

 

Thanks
Warren

 

<apex:page sidebar="false" showHeader="false" controller="SearchProjectsController">
   <apex:form id="form"> 
      <apex:commandButton value="Search Projects" action="{!searchProjects}" reRender="projectList" />
      <apex:outputPanel id="projectList" rendered="{!doneSearch}">
         OPEN PROJECTS
      </apex:outputPanel>
   </apex:form>
</apex:page>


public class SearchProjectsController {

   public boolean doneSearch {get; set;}

   public SearchProjectsController() {
      doneSearch = false;
   }

   public PageReference searchProjects() {
      doneSearch = true;
      projects = [SELECT Id, Name, Title__c FROM Project__c];
      return null;
   }
}

 

I have seen a couple posting on this from sometime ago, but have not seen any solutions.    I have logic that sends emails to owners of Opportunties that have not updated them for 30 days based on the LastModifiedDate of the record.  The code in my test class cannot trigger this condition because I am unable to insert a test record with a LastModifiedDate from 30 days ago.  Anyone have a solution for this?  Thanks.

Hello, what are the rules for the on-site finalist presentations? Main question: how much time will be given to present?

 

Thanks!

  • November 02, 2013
  • Like
  • 0

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!

  • October 23, 2012
  • Like
  • 0

We're looking for good engineers that have solid CS background along with good Force.com skills for a full time position at Twitter's San Francisco HQ.

Job details are here: https://twitter.com/jobs/positions?jvi=oTpjWfwh,Job

 

If interested send me an email at s.arsunukayev at gmail dot com

  • October 03, 2012
  • Like
  • 0

Contact has 2 fields:

1. a custom lookup field to User: User__c

2. a custom cross-object formula field that pulls a custom field from User: User_Field__c

 

According to Apex documentation the step below executes after the 'after trigger':

"If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the

roll-up summary field in the parent record. Parent record goes through save procedure."

 

Questions:

1. Is it guaranteed that I will always see the value of the User_Field__c field in Contact's after insert trigger? In my tests I can see the value coming through - does this fact contradict with the statement in documentation?

2. What does cross-object workflow mean in this specific context?

Problem # 1 is that sortBy attribute of the articleList component stops working after a keyword is specified. For instance, the code below renders the same result regardless of the sorting method:

 

<apex:page >
	<knowledge:articleList articleVar="article"
				sortBy="title"
				keyword="yourKeyword"
			>
				<li >
				<a href="{!URLFOR($Action.KnowledgeArticle.View, article.id) + '&popup=true'}" target="_blank">
				{!article.title}</a>
				</li>
				<apex:variable var="isArticlesResult" value="true"/>
						</knowledge:articleList>
	<br/>
	<knowledge:articleList articleVar="article"
				sortBy="mostViewed"
				keyword="yourKeyword"
			>
				<li >
				<a href="{!URLFOR($Action.KnowledgeArticle.View, article.id) + '&popup=true'}" target="_blank">
				{!article.title}</a>
				</li>
				<apex:variable var="isArticlesResult" value="true"/>
			</knowledge:articleList>
	<br />
	<knowledge:articleList articleVar="article"
				sortBy="lastUpdated"
				keyword="yourKeyword"
			>
				<li >
				<a href="{!URLFOR($Action.KnowledgeArticle.View, article.id) + '&popup=true'}" target="_blank">
				{!article.title}</a>
				</li>
				<apex:variable var="isArticlesResult" value="true"/>
	</knowledge:articleList>                   
</apex:page>

 

 

Whereas if keyword is removed sorting starts working.

 

Problem # 2 is that when keyword is specified, it is unclear what sorting criteria is used (it's not one of the 3 documented)

API version used for testing: 21, 22

I am experiencing a strange behavior with Data Loader’s bulk mode:

It doesn’t properly match error messages to the rows that caused the errors.

For instance, say we have the following data in the source CSV file [data is broken into 3 batches by the DL]:

1 data1

2 data2

3 data3

 

If data3 row caused an error DL can ‘lie’ saying that data2 caused it.

I believe this has something to do with the way DL breaks down data into batches.

I thought that if I enabled the sequential mode the issue would be gone, but it still doesn’t work

Has anyone experienced the same thing?

 

P.S. pressing 'Preview' tab in IE 8 deletes what you typed in the post!

  • March 08, 2011
  • Like
  • 0

I have a zip file that contains a javascript file and an image uploaded as a static resource.

My javascript needs to reference the image:

 

var myVar{

myImage: 'myImage.gif'

};

 

Problem is that on a Visual force page, when I include my static resource, image's URL is not resolved properly, it is:

https://c.cs4.visual.force.com/apex/images/myImage.gif

While javascript file's URL is right:

https://c.cs4.visual.force.com/resource/timeStamp/myJsFile.js

 

How do I reference the image from javascript so that it's URL is properly resolved?

 

Thanks!

 

P.S. A similar issue was raised here

  • January 18, 2011
  • Like
  • 0

We're using Exchange server and Mac machines with iCal and Mail applications.

Problem: How to sync salesforce calendar with Exhcange/iCal calendar?
Thanks!

 

  • December 14, 2010
  • Like
  • 0

I have a custom picklist field on the Case object. Each value in a picklist has a manually assigned chart color.

I created a summary report where grouping is based on the custom picklist.

Problem: report's chart doesn't show the assigned chart colors for the picklist. What am I doing wrong here?

 

Thanks!

  • December 02, 2010
  • Like
  • 0

Is there any way to share an account record with a role using Apex? As far as I know the answer is 'no', unless somebody has figured it out.

 

The problem is:

UserOrGroupId is a reference to a Group or User, NOT a Role, because of this I cannot link AccountShare record to a role, or create a GroupMember linked to a role.

 

  • November 02, 2010
  • Like
  • 0

Is Salesforce Knowledge available in Customer Portal?

 

thanks! 

  • January 31, 2010
  • Like
  • 0

Hello,

 

Is there any way to determine if a user has 'View all' object permission using Salesforce API?

 

Example: user has Read, Create, Edit, Delete, and View All permission for Account.

I can detect the first 4 permissions through API, but don't know how to get the 'View All' permission.

 

Is there any way of doing this?

  • January 21, 2010
  • Like
  • 0

I have an Apex method exposed as a web service. The method accepts an array of Opportunities: myMethod(Opportunity[]) and performs some logic.

 

 

Question:

What is the max number of Opportunities that can be passed to the method? 

My assumption is that it is 200, similar to the Salesforce API limitation, but I couldn't find a document to prove that.

 

 

Side question: what if my method accepted other objects/types, such as String[] for instance - would that affect the batch size? 

 

 

Thanks,

Shamil 

  • October 16, 2009
  • Like
  • 0

I've been struggling to find an answer to a pretty simple question:

Can Apex Code that makes callouts to external web services be installable in PE?

Apex would be a part of managed certified package.

 

Thanks,

Shamil

  • August 10, 2009
  • Like
  • 0
describeSObjectResult

object has a boolean flag called 'custom' that indicates whether a SObject is custom or not.

At the same time any custom object has a "__c" suffix.

 

Question: is it reliable to distinguish custom objects based on the 3 character suffix - "__c" rather than making an API call to SFDC merely to determine if an object is custom?

 

Pro's of checking for "__c" are:

1. Less API calls

2. Works a lot faster for multiple objects.

I am trying to get Task Owner's Mobile Phone number using the following SOQL:

 

Select  t.Owner.MobilePhone from Task t

 

When I try to execute it I get an error message:  "No such column 'MobilePhone' on entity 'Name'"

 

The error shows up for some other columns too, e.g. CallCenterId (of User object), while some I am able to get data for some other columns, such as Name, LastName, etc.

 

Why is that?

 

 

 

Message Edited by Shamil on 07-02-2009 10:15 AM

Where can I get an earlier version of Force.com WSDL file?

 

Thanks!

Does the Login() API call count agains the particular org's API limits?

How many emails can the sendEmail  Apex method send out per day?

 

I went through the documentation, and here is what is says:

a. "All mass email and single email messages sent with the sendEmail method count against the daily mass mail limit of the sending organization."

 

b. "You can send mass email to a maximum of 1000 external email addresses per day based on Greenwich Mean Time (GMT)."

 

Statement 'b', in my opinion means that you can send emails to maximum 1000 distinct email addresses per day, but it says nothing about the number of actual email messages being sent.

 

 

Thanks.

Question is:

Say, there is an existing app (a managed package) created 2 years ago. I want to create a next version of the app.
I assume I need to use the same developer org to create the next package version because namespace prefix has to be the same. Or is there a way to create an upgrade from
another dev org? What options are there?


Thanks!

Hello, I am having tough times finding an answer to a question:

Can a managed package have callouts from Apex to an external API and still be installable in PE?

 

 

Many thanks!

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!

  • October 23, 2012
  • Like
  • 0

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

  • May 02, 2012
  • Like
  • 0

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

  • April 30, 2012
  • Like
  • 0

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:))))

  • April 30, 2012
  • Like
  • 0

 

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?

  • April 29, 2012
  • Like
  • 1

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

 

  • April 26, 2012
  • Like
  • 0
<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.