• JPClark3
  • NEWBIE
  • 350 Points
  • Member since 2010

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 92
    Replies

Hi,

 

I'm using a static recursive variables for my triggers and I am encountering an issue when testing. I have 2 triggers. One on a custom object called procedure and another on custom object revenue that updates a procedure when inserted.

 

So in my test class I insert a procedure record, the first trigger runs and at the end sets the recursive variable hasRun = True.

 

Now when I go an insert my Revenue record, I want it to run through the procedure trigger again, but hasRun still equals to True? Do you need to reset static variables like that in test cases because test classes are considered a single execution state?

 

  • October 03, 2013
  • Like
  • 0

All,

 

I have a trigger that sets up new users to follow specific groups and unfollows when users are deactivated. The code works fine, but the test code doesn't. This is because the trigger calls future methods (which I want), but ironically enough, they're not being called quickly enough when I'm setting up the test data for testing. By the time the test starts, I need existing users to be members of the groups (so I can de-activate them), but my code is de-activating the user BEFORE the async has auto-followed them to the group.

 

I know that stopTest() ensures that all the async jobs have been completed. But does StartTest() not ensure that any async methods called during the initial test data creation has completed before the testing begins?

 

Andy

hi there,

friends I have a vf page that generating pdf and that page has a controller that is getting data from a master object and also from it's multiple child records using fieldsets the both objects having it's own fieldset and now when I'm doing

ApexPages.StandardController controller;
        productionEditControl proController = new productionEditControl(controller);
       
        //inserting test data... contains one production ticket and production line item under it...
        production__c p = new production__c();
        p.name = 'new test prodution 0011112';
        insert p;
       
        List<ProductionLineItem__c> plis = new List<ProductionLineItem__c>();
        for(Integer i = 0; i<=3; i++){
            productionLineItem__c pli = new productionLineItem__c();
            pli.production__c = p.id;
            plis.add(pli);
        }
        insert plis;
       
        // now passing the id to related page to use that data inserted above...
        PageReference pageRef = Page.EditProductionTicket;
        pageRef.getParameters().put('id', p.id);
        Test.setCurrentPage(pageRef);
       
        // calling instance methods...
        proController.save();
        proController.cancel();


it's giving me an error saying .... List has no rows for assignment to SObject so please tell me how to solve it..

 

thanks in advance.....

  • October 02, 2013
  • Like
  • 0

This is my first time writing a Apex Class. I have created a visual force page for a custom object. The purpose of the visualforce page is to be a PDF version of the custom object detail page.

 

When I try to save the Apex Class in my SANDBOX, I receive the following  Error: Compile Error: unexpected token: 'Program' at line 2 column 14

 

I interested the APEX CLASS code and VisualForce page code in this post.

 

I appreciate any help I can get in resolving this error. 

 

 Below is the APEX CLASS code:

 

public class ApprovedFundedProgramRequestPDF{
public Funded Program Request;
public DateTime craDateTime = DateTime.now();
private ApexPages.StandardController stdController;

public ApprovedFundedProgramRequestPDF(ApexPages.StandardController stdController){
    this.stdController = stdController;
    fpr = (Funded_Program_Request__c)stdController.getRecord();
}        

// Attach Approved Funded Program Request to current Funded_Program_Request__c

public PageReference attachApprovedFundedProgramRequestPDF(){
            
// Get the page definition 
PageReference pdfPage = Page.ApprovedFundedProgramRequestPDF;

// Generate the pdf blob
Blob pdfBlob = pdfPage.getContent();

// Create the attachment against the Approved Funded Program Request page 
Attachment a = new Attachment(parentId = opp.id, name=opp.name + ' - CRA ' + craDateTime.formatlong() + '.pdf', body = pdfBlob);
        
// Insert the attachment into the Funded Program Request
insert a;

// Send the user back to the events detail page
return stdController.view(); 
}

}

 Below is the VisualForce page code:

<apex:page > standardController="Funded_Program_Request_c" standardStylesheets = "false" showHeader="false" renderAS="pdf" 

extension="ApprovedFundedProgramRequestPDF">
    <body>
        <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
         <center><apex:image value="{!URLFOR($Resource.QLogicLogos,'ultimate_logo_horiz_blue_on_white_small.jpg')}"/></center>
        <center><u>
            <apex:outputText value="{!$Organization.Street}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}" style="font-

size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.Phone}" style="font-size:12px"/>  
        </u></center>   
        <br></br><br></br>
        <br></br><center><apex:outputText value="Approved Funded Program Request" style="font-weight:bold; font-size:30px" 

/></center><br></br>
        <b> Date: </b> <apex:outputText value=" {!NOW()}" /><br></br><br></br>
        <br></br><center><apex:outputText value="Program Summary" style="font-weight:bold; font-size:20px" /></center><br></br>
        <b> Funded Program Name: </b> <apex:outputText value="{!Funded_Program_Request_c.Name}" /><br></br><br></br>
        <b> Funded Request Status: </b> <apex:outputText value="{!Funded_Program_Request_c.Funded_Request_Status__c}" 

/><br></br><br></br>
        <b> Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request_c.Source_Of_Funding__c}" /><br></br><br></br>
        <b> Other Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request_c.Other_Source_of_Funding__c" 

/><br></br><br></br>
        <b> Theater: </b> <apex:outputText value="{!Funded_Program_Request_c.Theater__c}" /><br></br><br></br>
        <b> Goal Alignment: </b> <apex:outputText value="{!Funded_Program_Request_c.Goal_Alignment__c}" /><br></br><br></br>
        <b> Product Focus: </b> <apex:outputText value="{!Funded_Program_Request_c.Theater__c}" /><br></br><br></br>
        <b> Other Product: </b> <apex:outputText value="{!Funded_Program_Request_c.Other_Product__c" /><br></br><br></br>
        <br></br><br></br>
        <br></br><center><apex:outputText value="Payment Information" style="font-weight:bold; font-size:20px" 

/></center><br></br><br></br>
    	<b> Partner(Company Name): </b> <apex:outputText value="{!Funded_Program_Request.Partner__c}" />
        <br></br> <br></br><b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_r.Street_Name__c}" />  
            <apex:outputText value="{!Funded_Program_Request_r.City__c}" />   
            <apex:outputText value="{!Funded_Program_Reques_r.PostalCode__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_r.Partner_Contact__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_r.Contact_Email__c}" />   
            <apex:outputText value="{!Funded_Program_Request_r.Contact_Phone__c}" />
        </apex:panelGrid></b>
    	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Method_of_Payment__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.QLogic_Credit_Memo__c}" />   
            <apex:outputText value="{!Funded_Program_Request_C.QLogic_PO__c}" />
        </apex:panelGrid></b>
	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Payment_Due_Date__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.Company_Tax_ID__c}" />   
            <apex:outputText value="{!Funded_Program_Request_C.Quote_Provided__c}" />
        </apex:panelGrid></b>
        <br></br><br></br>
<br></br><center><apex:outputText value="Program Review" style="font-weight:bold; font-size:20px" /></center><br></br><br></br>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Activity_Date__c}" />  
            <apex:outputText value="{!Funded_Program_Request_c.Event_Format__c}" />   
            <apex:outputText value="{!Funded_Program_Reques_c.Other_Format__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Call_to_Action__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.Budget_Line_Item__c}" />   
            <apex:outputText value="{!Funded_Program_Request_c.Existing_Budget_Line_Item__c}" />
        </apex:panelGrid></b>
  	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Funding_Requested__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.How_will_Performance_be_Measured__c}" />   
            <apex:outputText value="{!Funded_Program_Request_c.Estimated_Performance_Value__c}" />
        </apex:panelGrid></b>
        <br></br><br></br>
        <br></br><br></br>
    </body>
</apex:page>

 

 

This should be a relatively simple request I think, but I can't find another example that has the specifics I need.

 

I would like to update one object based on changes made to another object where one string is equivalent.  In this case, I have a custom object (Customobj__c) that has a trigger on it to update a case with fields from that custom object based on a field that they both have in common.  One of the fields I want to update is a multi-select picklist, too (Event_Types__c).  The primary weirdness I am encountering is that the multi-select picklist doesn't always update when I save the Custom Object record, but I also suspect my code isn't laid out efficiently.  Can anyone help?

 

Here's the code:

 

trigger OnCustobjCaseFields on Customobj__c (before insert, before update)
{
String objSharedField; String objRecordId; String objAccount; String objEventTypes; for(Customobj__c obj: Trigger.new) { if (obj.Shared_Field__c != Null) { objSharedField = obj.Shared_Field__c; objRecordId = obj.Id; objAccount = obj.Account__c; objEventTypes = obj.Event_Types__c; } } List<Case> cases = new List<Case>([SELECT Id, Shared_Field__c, AccountId, Expected_Event_Types__c FROM Case WHERE Shared_Field__c = :objSharedField]); List<Case> caseUpdateList = new List<Case>(); for(Case c: cases) { c.AccountId = objAccount; c.App__c = objRecordId; c.Expected_Event_Types__c = objEventTypes; caseUpdateList.add(c); } if(caseUpdateList.size() > 0) { update caseUpdateList; } }

 

  • September 30, 2013
  • Like
  • 0

Hi,

 

Does anybody know how I can get all Lead Sources, created in the specific org, from within APEX code?

 

 

Thanks!

I had a problem where my trigger was calling a class twice. To avoid the class from being called twice, i have created a Boolean Field is_class-called__c on the Object and setting it to 'True' in the trigger. This solves my problem for now, but I can sense some unforseen situations when the class won't be called when it should be because the flag is not reset to 'False'

How can i reset the flag to false?

 

 if( trigger.isUpdate ){
                
       
        list<Record__c> rs = new list<Record__c>(); 
        rs = trigger.new;
        
        for( Record__c r :rs){
            
	        if( r.Status__c == 'Assigned'  && r.Date__c==Date.today() && r.is_class_called__c == false ){
	            
	            
	            class.callMethod(r.Id, r.Status__c, UserInfo.getUserId(), 'New');
	            
	            
	           r.is_class_called__c  = true;
	        
	        } 
	      
	    
        }

 

 

I am trying to use the following formula but I am getting a syntax error.  Can someone tell me what I am doing wrong?

 

if(First_Report_Due_Date__c > 30, "2", if(First_Report_Due_Date__c > 60, "3",  "1"))

 

i am trying to populate a text field to fill in the number of elapsed months.

 

thanks,

 

Mirko

I'm trying to create a trigger on Opportunities that will create a new account when a box on the opportunity is checked, then update a lookup field on that same opportunity with the newly created account.  I'm getting a self-reference error.

 

Here is the trigger:

 

trigger

CreateHybridAcct onOpportunity (beforeupdate) {

 

for

(Opportunity p : [SELECT ID, ACCOUNT.Name, ACCOUNT.ID, ACCOUNT.Client_Name__c, Create_Hybrid__c, Ownerid

 

FROM OPPORTUNITY WHERE ID in :Trigger.new]){

 

if(p.create_hybrid__c == True) {

 

Account h = newAccount(

name =

'testhybrid',

agency_id__c =

'300',

cmr_number__c =

'997',

client_name__c = p.account.name,

hybrid_account__c = p.account.id,

//owner = p.owner,

lead_converted_date__c = date.

today()

 

//recordtypeid = '01270000000UHZcAAO',//parentid = '0017000000PgOvrAAF'

);

inserth;

 

p.hybrid_account__c = h.id;

p.create_hybrid__c =

false;

 

updatep;

 

}

 

}

}

 

Here's the error message:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CreateHybridAcct caused an unexpected exception, contact your administrator: CreateHybridAcct: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0067000000LJK3FAAX; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 0067000000LJK3F) is currently in trigger CreateHybridAcct, therefore it cannot recursively update itself: []: Trigger.CreateHybridAcct: line 25, column 5
 
 
What can I do to get around this error message?  Inserting the new account does me no good if I can't tie it back to the opportunity.
 
Thanks!
  • September 26, 2011
  • Like
  • 0

...opportunity from .net using enterprise WSDL.

But it wont create due to Close date format issues.

 

i useed

opp1.CloseDate=System.convert.ToDateTime("23/03/2011").ToDate;

 

what is the correct way...i have been banging my head on this for long now :(

Hey all,

 

I've had this problem that's been bothering me for a few days here.  I'm trying to fill a call from a webservice into a pageblocktable, and I'm getting absolutely nowhere.  I've completed a workaround by instantiating a new datatable for each column I want to display, but I was wondering if there were any way to display this all in one table. 

 

Right now I have:

 

public class PageBlockTest
{
   public class TestThis
    {
        public List<Decimal> Line {get;set;}
        public List<String> INum {get;set;}
    }
    
    public List<TestThis> testMe = new List<TestThis> ();

    public List<TestThis> getTestData()
    {
        testMe = new List<TestThis>();
        TestThis tt = new TestThis();
        
        //The LineNumList and the ItemNumList are filled with the data from the webservice call.
        tt.Line = LineNumList;
        tt.INum = ItemNumList;
        
        testMe.add(tt);
        return testMe;
                
     }
}

 

And my visualforce code:

 

<apex:pageblock id = "myTest">
<apex:pageBlockTable value = "{!TestData}" var = "d">
<apex:column> 
    {!d.Line}
</apex:column>
<apex:column>
    {!d.INum}
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>

 

And I get the entire contents of the list in one field row.  How do I make them display like a table should?

 

 

When attempting to get the WSDL file from our development ORG, the file come down incomplete.

 

To access the Tooling API WSDL, from Setup, click Develop > API and click Generate Tooling WSDL.

 When I do this, the file retrieved is incomplete.

I've tried it in multiple ORGs with multiple browsers.

I'm attempting to authenticate between two ORGs using OAuth2. 

It seems to be working OK, except after I authenticate the remote ORG, I have to log-back-in to the client ORG for the callback to record the access token.

 

I've attempted adding the existing session ID onto the call back URI, but it gets lost.

 

string sessionId = UserInfo.getSessionId();
string OpenCallback = service.Redirect_URI__c+'?access_token=' + sessionId;
callbackUrl = EncodingUtil.urlEncode(OpenCallback, 'UTF-8');

 Has anyone else been able to authenticate between ORGs this way?

 

Thanks

I'm trying build a soql query to find all the parent records that don't have any child records in a "Lookup Relationship". Not Master-Datail relation ship.

 

For example, find all Accounts with no Contacts. 

 

I've tried this:

 

list<Account> accs = [SELECT ID FROM Account WHERE ID NOT IN (SELECT Account.Id FROM Contact)];

 This works in ORGs wothout too many Contacts, but isn't efficient, and will crash if there are more than 50K Contacts.

 

Ideas?

 

Thanks,

I'm attempting to get the BrandTemplate along with the EmailTemplate in a single statement, instead of two.

I have a function that takes the EmailTemplateID, and I query the EmailTemplate information, including the BrandTemplateID. Then I Query the value of the BrandTemplate using the BrandTemplateID. But I want to make that into a single statement, to save on queries.

 

I know I can do this to get Owner information on an object such as an Account when it has OwnerId:

Account theAcc = [Select Name, ID, Owner.Name, From Account Where ID = '...'];

 

Since the EmailTemplate has BrandTemplateID, I suspect I could do this:

        EmailTemplate ET = [SELECT ID, Name, FolderID,Folder.Name, ApiVersion , Body , 
                            Description ,DeveloperName , Encoding , 
                            HtmlValue , IsActive, Markup, NamespacePrefix , OwnerID, 
                            Subject, TemplateStyle, TemplateType,
                            BrandTemplate.Value   
                            FROM EmailTemplate WHERE ID = :EmailTemplateID  ];

 

But it says that it doesn't understand relationship BrandTemplate.

I'm attempting to use the Blob.toPdf function sending in an HTML string. The resulting PDF is not very well formatted. 

In the code below, I'm attempting to create a couple of tables and line up columns. The html works when I perform the "RenderAs=PDF" in a visual force page. I'm trying to replicate that using the Blob.toPDF() function.

 

 

Here is the test program I'm trying to run. If you paste this into an apex class, you can cut an paste the code inside the "testBlobPDF" and in an anonymus window and execute.

 

/**
 * Testing the ability to convert a string to a PDF file.
 */
@isTest
public class testBlobToPDF 
{

    public static testMethod void testBlobPDF() 
    {
        string PDFBody = testBlobToPDF.Body();
        Blob pdfBlob = Blob.toPDF(PDFBody);
        testBlobToPDF.SaveBlobToDoc(pdfBlob);
    }
    
    public static void SaveBlobToDoc (Blob blobPDF)
    {
    	string FileName = 'TestPDF';
    	Document doc;
    	list<Document> docs = [Select ID, Name, Body, FolderID, DeveloperName, Type, ContentType From Document Where Name = :FileName];
    	if (docs.size() > 0)
    		doc = docs[0];
    	else
    	{
    		doc = new Document();
    		doc.Name = FileName;
    		doc.DeveloperName = FileName;
    		doc.Type = 'pdf';
    		doc.ContentType = 'application/pdf';
    		doc.FolderId = UserInfo.getUserId();  //PLaces this into the persons Personal Folder
    	}
    	
    	doc.Body = blobPDF;
    	upsert doc;
    }
    
    public static string Body()
    {
    	string bodyStr = 
'    <div style="position: absolute; width: 8.0459in; height: 10.1124in; font-family: Verdana; font-size: 11.0pt">' + 
'      <table width="100%" border="0" cellspacing="0" cellpadding="2" style="font-weight: bold">	' +
'        <tr>	' +
'            <td width="35%" style="vertical-align: top" align="left">	' +
'                Appointment For: 4/5/2012  1:00 PM	' +
'            </td>	' +
'            <td width="35%" style="vertical-align: top" align="left">	' +
'                improveit! 360, Dev0	' +
'            </td>	' +
'            </tr>' +
'       </table>' +
'    <table width="100%" cellspacing="0" cellpadding="2">	' +		
'        <tr>			' +
'            <td width="45%" style="vertical-align: top">		' +	
'                <table width="100%" border="0" cellspacing="0" cellpadding="2">		' +	
'                    <tr>			' +
'                        <td style="vertical-align: top" width="25%" >			' +
'                            Name(s):			' +
'                        </td>			' +
'                        <td  width="75%" >			' +
'                            Christopher Miller	' +	
'                        </td>			' +
'                    </tr>			' +
'                    <tr>			' +
'                        <td style="vertical-align: top" width="25%" >			' +
'                            Address:			' +
'                        </td>			' +
'                        <td  width="75%" >			' +
'                            420 Pine Blvd.<br />			' +
'                            Stockton-515887724, VA 43201<br />			' +
'                        </td>			' +
'                    </tr>			' +
'                    <tr>			' +
'                        <td style="vertical-align: top" width="25%" >			' +
'                            Phone(s):			' +
'                        </td>' +			
'                        <td  width="75%" >' +			
'                            (234) 373-8468 Home<br />' +			
'                            (233) 246-8194 Home<br />' +			
'                             			' +
'                        </td>			' +
'                    </tr>' +			
'                </table>' +			
'            </td>' +			
'            <td width="45%" style="vertical-align: top">' +			
'                <table width="100%" cellspacing="0" cellpadding="2" style="border: 1px solid black;">' +			
'                    <tr>' +			
'                        <td style="vertical-align: top" width="25%" >' +			
'                            Status:' +			
'                        </td>' +			
'                        <td  width="75%" >' +			
'                            Assigned' +			
'                        </td>' +			
'                    </tr>' +			
'                    <tr>' +			
'                        <td style="vertical-align: top" width="25%" >' +			
'                            Type:' +			
'                        </td>' +			
'                        <td  width="75%" >' +			
'                            New			' +
'                        </td>' +			
'                    </tr>' +			
'                    <tr>' +			
'                        <td style="vertical-align: top" width="25%" >' +			
'                            Date / Time:' +			
'                        </td>' +			
'                        <td  width="75%" >' +			
'                            4/5/2012  1:00 PM' +			
'                        </td>' +			
'                    </tr>' +			
'                    <tr>' +			
'                        <td style="vertical-align: top" width="25%" >' +			
'                            Duration:' +			
'                        </td>' +			
'                        <td  width="75%" >' +			
'2' +			
'                        </td>' +			
'                    </tr>' +			
'                    <tr>' +			
'                        <td style="vertical-align: top" width="25%" >' +			
'                            Rep 1:' +			
'                        </td>' +			
'                        <td  width="75%" >' +			
'                            Jeff Clark' +			
'                        </td>' +			
'                    </tr>' +			
'                    <tr>' +			
'                        <td style="vertical-align: top" width="25%" >' +			
'                            Rep 2:' +			
'                        </td>' +			
'                        <td  width="75%" >' +			
'                        </td>' +			
'                    </tr>' +
'                </table>' +			
'            </td>' +			
'        </tr>' +			
'        </table>' +			
'     </div>';
		return bodystr;
		
    	
    }
}

 

 

Thanks in advance,

 

Jeff Clark

I'm attempting to retrieve XML from a VF page, but I'm not receiving XML, only some javascript.

I have a simple page:

<?xml version="1.0" encoding="UTF-8"?><apex:page contentType="application/xml">
<result>
{!$CurrentPage.parameters.ResultString}
</result>
</apex:page>

 with being redirected to by the result of a different controller:

ResultString = '<reason>' + NewProspectStatus + '</reason>';
if(NewProspectStatus.startsWith('New Lead: '))
{
	ResultString = '<code>0</code>\n<description>SUCCESS</description>\n' + ResultString;
}
else
{
	ResultString = '<code>1</code>\n<description>ERROR</description>\n' + ResultString;
}
system.debug('ResultsString: ' + ResultString);
Pagereference pr = Page.ELeadThankYou;       
pr.getParameters().put('ResultString', ResultString);
pr.setRedirect(true);
system.debug('Response: ' + pr.getContent().toString());
return pr;

 But the result looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script>
var escapedHash = '';
var url = '/eleadthankyou?ResultString=%3Ccode%3E0%3C%2Fcode%3E%0A%3Cdescription%3ESUCCESS%3C%2Fdescription%3E%0A%3Creason%3ENew+Lead%3A+Buddy+Dwight+imported+from+Lead+Provider%3A+FromORG2%3C%2Freason%3E';
if (window.location.hash) {
   escapedHash = '%23' + window.location.hash.slice(1);
}
if (window.location.replace){ 
window.location.replace(url + escapedHash);
} else {;
window.location.href = url + escapedHash;
} 
</script>
</head>
</html>

 

 

 

I've read through this post

Generating an XML from VF page using ContentTyp​e

Which is a nice intro to what I'm attempting.

 

Any idea why this is not returning XML?

 

I have a page that I've set for the site home page. The controller is querying a custom object (Interest Selections) to display a list of check boxes.

I've set the object access to read-only for the web site user profile (and even tested with full access writes). But the page fails to load when reading from this object.

VF Page:

 

<apex:page Controller="tempELeadImportController" id="ELeadImportPage" showheader="false" sidebar="false" >
 <apex:pageBlock title="Import Detail"  > 
  <apex:OutputText value="{!NewProspectStatus}" /> 
 </apex:pageBlock> 
 <apex:form id="ELeadImportForm" > 
   <!-- other items here that work --> 
   <apex:pageBlockSection showHeader="true" title="I'm interested in" columns="1" collapsible="false">
 
     <apex:selectCheckboxes id="Components" title="Components" value="{!SelectedComponents}" > 
     <apex:selectOptions value="{!ComponentSelections}"/> 
     </apex:selectCheckboxes> 

   </apex:pageBlockSection> 
  </apex:pageBlock> 
 </apex:form> 
</apex:page>

 

 

Apex controller where "ComponentSelections are being created:

global List<SelectOption> ComponentSelections
{
 get
 {
  set<string> componentNames = new set<string>();
    
    // Query the interest selection table to find all the components that are in there. - Note if there are more than 10k records this will break.
    AggregateResult[] validComponents = [SELECT i360__Component__c 
                                        FROM i360__Interest_Selection__c 
                                        WHERE i360__Component__c != null GROUP BY i360__Component__c];
    system.Debug(validComponents);
    for(AggregateResult ar : validComponents)
    {
        string component = (string) ar.get('i360__Component__c');
        componentNames.add(component);
    }
    List<SelectOption> Components = new List<SelectOption>();
    for (string src : componentNames)
    {
        SelectOption option = new SelectOption(src, src);
        Components.Add(option);
    }
    system.Debug(Components);
    return Components;       
  }
}

 

 Even when the web site user profile has FULL access to the "Interest Selections" object, the user cannot read those values. If I change the controller to "without sharing" [WHICH I KNOW IS NOT THE CORRECT FIX] then everything works. Therefore, there is something else stopping the access to these values.

 

 

This just started today (9/26/2011) and won't let me save the file to force.com. The file is a long existing apex class. Only making some minor changes.

 

 

Save error: Unable to perform save on all files:

 

com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor

 

I deleted the whole project and re-added it. I was able to get everything back, then tried to make changes again. Same error. I tried to refresh my file from the ORG and received a pop up with the same error.

 

 

 

Web Services API guide says:

MailmergeTemplate

Represents a mail merge template (a Microsoft Word document) used for performing mail merges for your organization.

Supported Calls

create(), delete(), getDeleted(), getUpdated(), query(), retrieve(), undelete(), update(), upsert(), describeSObjects()

 

 

But this Apex code doesn't compile:  

Save error: DML not allowed on MailmergeTemplate testMoveToMailMerge.cls /i360/src/classes line 12

public class testMoveToMailMerge 
{
public static MailmergeTemplate MoveFile(string FileName, string TemplateName)
{
Document doc = [Select ID, Body, BodyLength, ContentType, FolderID, Name, Description, DeveloperName, NamespacePrefix, Type, Keywords FROM Document WHERE Name = :FileName Limit 1];
System.Debug(doc);
MailmergeTemplate template = new MailmergeTemplate();
template.Name = TemplateName;
template.Body = doc.Body;
template.Description = doc.Description;
template.Filename = doc.Name;		
insert template;
MailmergeTemplate RetTemplate = [Select Name, Id, Filename, Description, BodyLength, Body From MailmergeTemplate WHERE Id = :template.Id];	
return RetTemplate;
}
public static testMethod void TestMove()
{
string FileName = 'TempTestMailMerge1';
string TemplateName = 'Ping Pong';
MailmergeTemplate template = MoveFile(FileName, TemplateName);
Document doc = [Select ID, Body, BodyLength, ContentType, FolderID, Name, Description, DeveloperName, NamespacePrefix, Type, Keywords FROM Document WHERE Name = :FileName Limit 1];
System.AssertEquals(template.Name, TemplateName);
System.AssertEquals(template.BodyLength, doc.BodyLength);
}
}

 

I have a requirement to allow third party lead providers to post XML lead data to our application and convert that into a custom object. I currently have it working by having the test client application attach the XML string as a query parameter:

(&leaddata=< ... xml ... />), and sending the httprequest without anything in the body of the post.

 

However, I don't think this is the expacted (or correct) way to post data to the site page. I would think the correct method would be to add the XML in the body of the "POST". The page controller uses the "getParameters()" method then uses the XML Dom to parse the XML. Everything works well after that.

 

My question is:

How would I get hold of the incomong HTTPRequest in the page controller to grab the body of the request?

 

I would expect something like this:

 

public MyController
{
  private string XmlString;
  public MyController()
  {
    HTTPRequest IncomingRequest = Pages.CurrentPage.GetRequest();
    Blob BodyBlob = IncomingRequest.getBody();
    XmlString = BodyBlob.ToString();
  }
}

 

Is there a way to use one of the APIs to install a package into an ORG?

 

We currently use a Selenium Script to do this, but I'd rather use one of the APIs to perform the install.

This is pretty strange. When spliting a string using a vertical bar, it appears to split between numerical characters also.

String.Split actually uses regular expressions to perform the split. So even though I'm using the same character, it is interpreted differently. This will be the case for other regeular expression characters also.

 

So the solution to this issue is to use two delimiters, one to join and one to split:

string DelJoin = '|';

string DelSplit = '\\|';

 

 

 

//Original test code:
public static testmethod void SplitTest() { string delim = '|'; string ToSplit = '-9.99999999911101E14' + delim + '1000011'; List<string> SplitValues = ToSplit.split(delim); System.Debug('@@@SplitTest:' + SplitValues); integer sz = SplitValues.Size(); System.AssertEquals(2, sz); //This fails with a value of 29 integer Pointer = integer.valueOf(SplitValues[sz-1]); System.Debug('@@@SplitTest:' + Pointer); System.AssertEquals(1000011, Pointer); }

 

 

I just installed the Version: Winter '11 (20.0.0) Force.com plug-in this morning.

Now I can't see and debug logs when running Unit Tests. The window in the bottom right only contains "No Debug Logs"

 

The debog log does show up when running in the browser.

 

My other developers are having this same problem. Is there a setting I'm missing? Has anyone else experienced this?

 

Thanks

Hi,

 

I'm using a static recursive variables for my triggers and I am encountering an issue when testing. I have 2 triggers. One on a custom object called procedure and another on custom object revenue that updates a procedure when inserted.

 

So in my test class I insert a procedure record, the first trigger runs and at the end sets the recursive variable hasRun = True.

 

Now when I go an insert my Revenue record, I want it to run through the procedure trigger again, but hasRun still equals to True? Do you need to reset static variables like that in test cases because test classes are considered a single execution state?

 

  • October 03, 2013
  • Like
  • 0

All,

 

I have a trigger that sets up new users to follow specific groups and unfollows when users are deactivated. The code works fine, but the test code doesn't. This is because the trigger calls future methods (which I want), but ironically enough, they're not being called quickly enough when I'm setting up the test data for testing. By the time the test starts, I need existing users to be members of the groups (so I can de-activate them), but my code is de-activating the user BEFORE the async has auto-followed them to the group.

 

I know that stopTest() ensures that all the async jobs have been completed. But does StartTest() not ensure that any async methods called during the initial test data creation has completed before the testing begins?

 

Andy

hi there,

friends I have a vf page that generating pdf and that page has a controller that is getting data from a master object and also from it's multiple child records using fieldsets the both objects having it's own fieldset and now when I'm doing

ApexPages.StandardController controller;
        productionEditControl proController = new productionEditControl(controller);
       
        //inserting test data... contains one production ticket and production line item under it...
        production__c p = new production__c();
        p.name = 'new test prodution 0011112';
        insert p;
       
        List<ProductionLineItem__c> plis = new List<ProductionLineItem__c>();
        for(Integer i = 0; i<=3; i++){
            productionLineItem__c pli = new productionLineItem__c();
            pli.production__c = p.id;
            plis.add(pli);
        }
        insert plis;
       
        // now passing the id to related page to use that data inserted above...
        PageReference pageRef = Page.EditProductionTicket;
        pageRef.getParameters().put('id', p.id);
        Test.setCurrentPage(pageRef);
       
        // calling instance methods...
        proController.save();
        proController.cancel();


it's giving me an error saying .... List has no rows for assignment to SObject so please tell me how to solve it..

 

thanks in advance.....

  • October 02, 2013
  • Like
  • 0

Hello!

 

I am trying to match commissions based on incentives, and divisions associated.  I have tried the following trigger but am fairly new to apex code when it comes to larger statements such as this one.  Can anyone help me out?  Here is my code

 

trigger CreateCommission on Commissionable_User__c (after insert ) {

for (Commissionable_User__c CU: trigger.new){

  Incentive_Plan__c[] InP = [Select Id, Spiff__c, of_Commissionable_Price__c, Division__c From Incentive_Plan__c Where Division__c = :CU.Commissionable_User_Division__c limit 1 ];
   Incentive_Product__c[] IPa=[Select Id,Intradivisional_Percentage__c,Interdivisional_Percentage__c,Division__c ,Incentive_Plan__c From Incentive_Product__c Where Product__c= :CU.ProductId__c  limit 1 ];
   
  If(IPa.Id<>CU.ProductId__c&&InP.Division__c==CU.Commissionable_User_Division__c){
     
    
  Commission__c commission = new Commission__c();
  commission.Commission_User_ID__c = CU.Id;
  commission.earn_date__c =date.today();
  commission.Incentive_Plan__c = InP[0].Id;
  commission.Percent__c=InP[0].of_Commissionable_Price__c;
  commission.CommissionSpiff__c=InP[0].Spiff__c;
   
   ||
   
   If(IPa.Id==CU.ProductId__c&&IPa.Division__c<>CU.Commissionable_User_Division__c){
   
   Commission__c commission = new Commission__c();
  commission.Commission_User_ID__c = CU.Id;
  commission.earn_date__c =date.today();
  commission.Incentive_Plan__c = InP[0].Id;
  commission.Percent__c=InP[0].Interdivisional_Percentage__c;
  commission.CommissionSpiff__c=InP[0].Spiff__c;
  
  ||
  
   If(IPa.Id==CU.ProductId__c&&IPa.Division__c==CU.Commissionable_User_Division__c){
   
    Commission__c commission = new Commission__c();
  commission.Commission_User_ID__c = CU.Id;
  commission.earn_date__c =date.today();
  commission.Incentive_Plan__c = InP[0].Id;
  commission.Percent__c=InP[0].Intradivisional_Percentage__c;
  commission.CommissionSpiff__c=InP[0].Spiff__c;
   
   else
   
   Commission__c commission = new Commission__c();
  commission.Commission_User_ID__c = CU.Id;
  commission.earn_date__c =date.today();
  commission.Incentive_Plan__c = InP[0].Id;
  commission.Percent__c=InP[0].of_Commissionable_Price__c;
  commission.CommissionSpiff__c=InP[0].Spiff__c;
  
  insert commission;
    
   
}
}






}

 

 

This is my first time writing a Apex Class. I have created a visual force page for a custom object. The purpose of the visualforce page is to be a PDF version of the custom object detail page.

 

When I try to save the Apex Class in my SANDBOX, I receive the following  Error: Compile Error: unexpected token: 'Program' at line 2 column 14

 

I interested the APEX CLASS code and VisualForce page code in this post.

 

I appreciate any help I can get in resolving this error. 

 

 Below is the APEX CLASS code:

 

public class ApprovedFundedProgramRequestPDF{
public Funded Program Request;
public DateTime craDateTime = DateTime.now();
private ApexPages.StandardController stdController;

public ApprovedFundedProgramRequestPDF(ApexPages.StandardController stdController){
    this.stdController = stdController;
    fpr = (Funded_Program_Request__c)stdController.getRecord();
}        

// Attach Approved Funded Program Request to current Funded_Program_Request__c

public PageReference attachApprovedFundedProgramRequestPDF(){
            
// Get the page definition 
PageReference pdfPage = Page.ApprovedFundedProgramRequestPDF;

// Generate the pdf blob
Blob pdfBlob = pdfPage.getContent();

// Create the attachment against the Approved Funded Program Request page 
Attachment a = new Attachment(parentId = opp.id, name=opp.name + ' - CRA ' + craDateTime.formatlong() + '.pdf', body = pdfBlob);
        
// Insert the attachment into the Funded Program Request
insert a;

// Send the user back to the events detail page
return stdController.view(); 
}

}

 Below is the VisualForce page code:

<apex:page > standardController="Funded_Program_Request_c" standardStylesheets = "false" showHeader="false" renderAS="pdf" 

extension="ApprovedFundedProgramRequestPDF">
    <body>
        <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
         <center><apex:image value="{!URLFOR($Resource.QLogicLogos,'ultimate_logo_horiz_blue_on_white_small.jpg')}"/></center>
        <center><u>
            <apex:outputText value="{!$Organization.Street}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}" style="font-

size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.Phone}" style="font-size:12px"/>  
        </u></center>   
        <br></br><br></br>
        <br></br><center><apex:outputText value="Approved Funded Program Request" style="font-weight:bold; font-size:30px" 

/></center><br></br>
        <b> Date: </b> <apex:outputText value=" {!NOW()}" /><br></br><br></br>
        <br></br><center><apex:outputText value="Program Summary" style="font-weight:bold; font-size:20px" /></center><br></br>
        <b> Funded Program Name: </b> <apex:outputText value="{!Funded_Program_Request_c.Name}" /><br></br><br></br>
        <b> Funded Request Status: </b> <apex:outputText value="{!Funded_Program_Request_c.Funded_Request_Status__c}" 

/><br></br><br></br>
        <b> Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request_c.Source_Of_Funding__c}" /><br></br><br></br>
        <b> Other Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request_c.Other_Source_of_Funding__c" 

/><br></br><br></br>
        <b> Theater: </b> <apex:outputText value="{!Funded_Program_Request_c.Theater__c}" /><br></br><br></br>
        <b> Goal Alignment: </b> <apex:outputText value="{!Funded_Program_Request_c.Goal_Alignment__c}" /><br></br><br></br>
        <b> Product Focus: </b> <apex:outputText value="{!Funded_Program_Request_c.Theater__c}" /><br></br><br></br>
        <b> Other Product: </b> <apex:outputText value="{!Funded_Program_Request_c.Other_Product__c" /><br></br><br></br>
        <br></br><br></br>
        <br></br><center><apex:outputText value="Payment Information" style="font-weight:bold; font-size:20px" 

/></center><br></br><br></br>
    	<b> Partner(Company Name): </b> <apex:outputText value="{!Funded_Program_Request.Partner__c}" />
        <br></br> <br></br><b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_r.Street_Name__c}" />  
            <apex:outputText value="{!Funded_Program_Request_r.City__c}" />   
            <apex:outputText value="{!Funded_Program_Reques_r.PostalCode__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_r.Partner_Contact__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_r.Contact_Email__c}" />   
            <apex:outputText value="{!Funded_Program_Request_r.Contact_Phone__c}" />
        </apex:panelGrid></b>
    	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Method_of_Payment__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.QLogic_Credit_Memo__c}" />   
            <apex:outputText value="{!Funded_Program_Request_C.QLogic_PO__c}" />
        </apex:panelGrid></b>
	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Payment_Due_Date__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.Company_Tax_ID__c}" />   
            <apex:outputText value="{!Funded_Program_Request_C.Quote_Provided__c}" />
        </apex:panelGrid></b>
        <br></br><br></br>
<br></br><center><apex:outputText value="Program Review" style="font-weight:bold; font-size:20px" /></center><br></br><br></br>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Activity_Date__c}" />  
            <apex:outputText value="{!Funded_Program_Request_c.Event_Format__c}" />   
            <apex:outputText value="{!Funded_Program_Reques_c.Other_Format__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Call_to_Action__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.Budget_Line_Item__c}" />   
            <apex:outputText value="{!Funded_Program_Request_c.Existing_Budget_Line_Item__c}" />
        </apex:panelGrid></b>
  	<apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request_c.Funding_Requested__c}" />  
            <apex:outputText value="{!Funded_Program_Reques_c.How_will_Performance_be_Measured__c}" />   
            <apex:outputText value="{!Funded_Program_Request_c.Estimated_Performance_Value__c}" />
        </apex:panelGrid></b>
        <br></br><br></br>
        <br></br><br></br>
    </body>
</apex:page>

 

 

I am having a problem with a class I am creating. I keep getting the following error. Any help would be greatly appreciated.

 

Save error: Initial term of field expression must be a concrete SObject: LIST<Extended_Warranty__c>

 

 

 

public with sharing class BL_extwntylistb {
    
        public List<Extended_Warranty__c> extwnty {get;set;}
   
    public Id extid;
    String Name;
    public BL_extwntylistb(ApexPages.StandardController controller)
{
      extId= controller.getRecord().Id;
   
     try
      {
       Account ext=[Select id From Account Where id=:extId];
      extwnty = [Select Name, Ext_Wnty_Desc__c,Ext_Wnty_Type__c  from Extended_Warranty__c where Id =: extwnty.Id ];
       
      }
      catch(Exception e)
      {
        system.debug('Exception'+e);
      }
     
  }
    

}

  • October 01, 2013
  • Like
  • 0

This should be a relatively simple request I think, but I can't find another example that has the specifics I need.

 

I would like to update one object based on changes made to another object where one string is equivalent.  In this case, I have a custom object (Customobj__c) that has a trigger on it to update a case with fields from that custom object based on a field that they both have in common.  One of the fields I want to update is a multi-select picklist, too (Event_Types__c).  The primary weirdness I am encountering is that the multi-select picklist doesn't always update when I save the Custom Object record, but I also suspect my code isn't laid out efficiently.  Can anyone help?

 

Here's the code:

 

trigger OnCustobjCaseFields on Customobj__c (before insert, before update)
{
String objSharedField; String objRecordId; String objAccount; String objEventTypes; for(Customobj__c obj: Trigger.new) { if (obj.Shared_Field__c != Null) { objSharedField = obj.Shared_Field__c; objRecordId = obj.Id; objAccount = obj.Account__c; objEventTypes = obj.Event_Types__c; } } List<Case> cases = new List<Case>([SELECT Id, Shared_Field__c, AccountId, Expected_Event_Types__c FROM Case WHERE Shared_Field__c = :objSharedField]); List<Case> caseUpdateList = new List<Case>(); for(Case c: cases) { c.AccountId = objAccount; c.App__c = objRecordId; c.Expected_Event_Types__c = objEventTypes; caseUpdateList.add(c); } if(caseUpdateList.size() > 0) { update caseUpdateList; } }

 

  • September 30, 2013
  • Like
  • 0

I'm new to Apex (and coding) and was wondeirng if it was possible to update fields from the EmailMessage.Textbody with an ApexTrigger rather than creating a custom inbound email handler service.  It seems like it would  be easier to just utilize the Email to Case On Demand feature, and have a trigger to parse the data from the default field that the email text body goes to on the Case.  So I know that I need to string the emailbody with substrings for where I want to start capturing the data, and I know that I want to set the string values equal to the Case fields.  Any other help setting this up would be appreciated.  So far I have code that looks like this, but it isn't functional since I don't know what I need to put in between the two statements to complete the code:

 

trigger TextBody on Case (before insert) {
String[] emailBody = email.plainTextBody.split('\n', 0);
String Site = emailBody[0].substring(17);
String State = emailBody[2].substring(25);
String Field1 = emailBody[4].substring(17);
String Field2 = emailBody[6].substring(18);
String Field3 = emailBody[8].substring(16);
String Field4 = emailBody[10].substring(17);
String Field5 = emailBody[12].substring(17);
String Codes = emailBody[14].substring(17);
String Name = emailBody[16].substring(17);
}

 

this.theCase = new Case();
this.theCase.Status = 'Open';
this.thCase.Priority = 'Low';
this.theCase.Site__c = Site;
this.theCase.State__c = State;
this.theCase. Field_1__c = Field1;
this.theCase. Field_2__c =  Field2;
this.theCase. Field_3__c =  Field3;
this.theCase. Field_4__c =  Field4;
this.theCase. Field_5__c =  Field5;
this.theCase.Codes__c = Codes;
this.theCase.Name__c = Name;
this.theCase.Origin = 'Email';
this.theCase.Subject = email.Subject;
this.theCase.Description = email.plainTextBody;

  • September 30, 2013
  • Like
  • 0

I have 2 loops that are causing some small problems.

 

In the code below you will note that I have two loops that hit the PriceBookEntry table (pbe1).  The first loop searches through out main production pricebook.  The second loop, loops through the PriceBookEntry table (pbe2) searching to find the productid in the standard pricebook.

 

The  PROBLEM:

 

When the first loop finds the productId I am looking for and grabs the listprice out of the main pricebook, it sometimes continues to loop through the second loop through the standard and then the update has two duplicate id's and blows to high hell and back.

 

Anyone that contributes will get kudos.

 

The person that gets me closest to the solution will get solution credit as well.

 

Here's the code:

 

public with sharing class MaintContractLineItemCreation 
{    
    Public static String ProductLineState = 'Not Found';
    Public static void ContractLineItemInsert(Map<Id,Contract_Line_Item__c> oldMap, Map<Id,Contract_Line_Item__c> newMap)
    {
    
    List<Id> CLIIds = new List<Id>();
    map<Id,String> CLIMap = new map <Id,String>(); 
    
    List<Id> Prodid = new List<Id>();
    
    List<id> PBE = new List<Id>();
    
    for (Contract_Line_Item__c c : newMap.Values())
    {   
        if(c.Product_LU__c != null)
        {      
             CLIIds.add(c.Id);
        }
    }
    
    for (Contract_Line_Item__c Prod : newMap.Values())
    {   
        if(Prod.Product_LU__c != null)
        {      
             Prodid.add(Prod.Product_LU__c);
        }
    }
    
    List<Contract_Line_Item__c> ContractLinesToUpdate = new List<Contract_Line_Item__c>();
    List<Contract_Line_Item__c> ContractLinesToUpdate1 = new List<Contract_Line_Item__c>();
    
    for(PriceBookEntry pbe1 :[Select id, UnitPrice, Pricebook2Id from PriceBookEntry where (Pricebook2id = '01s3000000001JS') and Product2id in :Prodid])
    
    {
                 
           
           for (Contract_Line_Item__c cli :[Select id, List_Price__c from Contract_Line_Item__c where id in :CLIIds])
           {
             ProductLineState = 'Not Found';
             if(pbe1.Pricebook2Id == '01s3000000001JS' && ProductLineState != 'Found' && pbe1.UnitPrice != null)
             {  
           
                cli.List_Price__c = pbe1.UnitPrice;
                ContractLinesToUpdate.add(cli);
                ProductLineState = 'Found'; 
                update(ContractLinesToUpdate);
             }
             }
    for(PriceBookEntry pbe2 :[Select id, UnitPrice, Pricebook2Id from PriceBookEntry where (Pricebook2id = '01s3000000004T2AAI') and Product2id in :Prodid])
    
    {
    for (Contract_Line_Item__c cli :[Select id, List_Price__c from Contract_Line_Item__c where List_Price__c = null and id in :CLIIds])
           {
             if(pbe2.Pricebook2Id == '01s3000000004T2AAI' && cli.List_Price__c == null &&  pbe1.UnitPrice != null)
                  {
                    cli.List_Price__c = pbe2.UnitPrice;
                    ContractLinesToUpdate.add(cli);
                    ProductLineState = 'Found'; 
                     update(ContractLinesToUpdate);
            }      }                 
           }  }
           
         }
        }

 Thank you,

Steve Laycock

I want a list of user that current user in not following in chatter , please help me I am new in this developer arena...

 

I got the list of cureent user's following

 

Select id, subscriberid  from entitysubscription where Subscriberid= "Userinfo.getuserid();

 

Regards,

Millik

  • September 30, 2013
  • Like
  • 0

Hi,

 

I am working on a requirement in which I am trying to insert a child record while creating the parent record.

 

My parent object is the Case Object and my child object is a Custom Object called People__c. Through the use of a Custom button, I would like to create a People__c record. Basically, when the user clicks the button on the case record, the user will be taken to the People__c object, all the necessary details can be filled in and once the people record is saved, the user will be redirected back to the case record that has not still been saved to the database.

 

I have never worked on a requirement like this before. Any suggestions or sample code would greatly help me out.

 

Thanks!

I am trying to get metadata for all objects using Partner API, 

 

got some samples in internet for calling binding .describeGlobal();

 

but when I am calling describeGlobal  its expecting   SessionHeader, CallOptions, PakageVersions[]

 

also there is no URL property for my binding object , and If I pass nulls for binding .describeGlobal(); instead of parameters, Giving following exception

 

UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService

 

 

Please somebody give me a code snippet to get Metada for all objects using partner API, I wanna use partner API because I want my code to work for any organization without any change.

 

Hello,

 

Integrating salesforce with twitter through apex code am facing error like

 

"Failed to validate oauth signature and token"

 

 

Am passing twitter Oauth token, secretkey... in string format like

 

string Stringval='Oauth_callback="'+EncodingUtil.urlEncode('https://c.ap1.visual.force.com/apex/twitterForcepage';, 'UTF-8')+'",oauth_consumer_key="eIGzjmMGeclmpSzxmjnKhQ", oauth_nonce="3de317379683f90d4f80da8879472036", oauth_signature="fiyY68Llzy2yREjUeJw0o%2Fdqcns%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1365504459", oauth_token="354671694-MrReLR18pmpDZulKaRVZR3CifKpI9ZFo1XUofyJn", oauth_version="1.0"';

 

string bVal=EncodingUtil.Base64Encode(blob.valueof(Stringval)); 
String authorizationHeader = 'Bearer :' + bval;
req.setHeader('Authorization',bVal);

 

 

How to integrate salesforce with twitter through apex? how to authenticate with twitter? or acess responce from twitter?

 

Can anyone suggest my issue where it is problem?




Thank you

I'm trying to bulk upsert some data, here is the structure

 

Account *parent*
Provider__c "child of Account*

Practice__c *child of Provider__c*

I always have the account id.

 

I need to add a new provider and its practices so I have something as follows.

 

Provider__c prov = new Provider__c;
Practice__c prac = new Practice__c;

prov.Account_Name__c = accountID;
prov.Name= "value";
...etc

prac.Provider__c = prov.ID
...etc

upsert(prov)
upsert(prac)

 
As you can see prov.ID is going to be empty so it flags an error trying to do the upsert.
How to I correctly link these items and upsert them?

Thanks

Its bad but its a limitation of SOQL I cant use

 

Select Id, First_Name__c As 'Name from Candidate

 

This is really very bad