• BryanHart
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 19
    Replies

I've got an SObject that is given to me by a webservice, which I have to update.

Unfortunatly, this object doesn't have an ID because the external service that made the request doesn't have it.

 

I can easily query for the ID, however the ID field is not writable, so I can't just set the sobject's ID and the do an update.

I can't just query the object, then copy over all the fields because I don't know which fields the external service wants me to update (don't want to accidently null out fields).

 

What is the best way to do an update on an object where the ID is known, but is not in the SObject itself?

I have a custom component that sits within a repeater.

the custom component's attribute is set via the repeater.

the custom component's attribute uses assignTo to set a property on its controller.

 

if (and only if) I use that attribute in the body of another custom component (inside the first custom component), then the attribute only sets the first time the repeater creates the component, never thereafter. I can access the visualforce attribute as expected... but the property on the controller is never set again.

 

I have a simple code example to illustrate the problem.

Note that the two case IDs ({!case.id} and {!myCase.id}) should be the same.

 

 

Any idea what is wrong?

 

*EDIT*

looking into it more...

the controller is being set properly, but the wrong value is being passed into the component body for some reason.

Its like {!myCase} only gets resolved once and gets reused for every repetition.

 

 

 

TestPage

<apex:page standardController="Contact">
 <apex:repeat value="{!Contact.Cases}" var="c">
   <div><c:TestComponent case="{!c}" /></div>
 </apex:repeat>
</apex:page>

 

 

TestComponent

<apex:component controller="TestComponentController">
    <apex:attribute name="case" type="Case" description="TODO" assignTo="{!myCase}"/>

    <c:TestComponent2>these should be the same: {!case.id}, {!myCase.id} </c:TestComponent2>
</apex:component>

 

TestComponentController

public class TestComponentController
{
    public Case myCase {get;set;}
}

 TestComponent2

<apex:component>
      <apex:componentbody/>
</apex:component>

 

HI everyone,

 

My requirement is dispalying percentage(%) marks. I done my requirement but in percentage field it display like 60.89% but it dispalys after record saved like 6089.00%. Any one can solve this problem.

 

i taken one formula field that is Percentage__c in thhis field i want to display Percentage of the semester.

Already i created one read ony filed is TotalMArks__C.

 

My formula Expression code is :

 

Total_Marks__c / 7

 

Any one can please help this one...

 

Thanks for your helping...............

Hello,

 

I have below apex trigger. AccountId field is coming as null when I am trying to login as well which has read-only access to the field account name which is lookup field to Account standard object.

 

This value is coming file when I am trying to raise a case with profile having "MODIFY ALL DATA" access but with normal user having read-only access to the field in coming as null.

 

Triggers run on system mode why there is discrepancy with login. Please help how to get this value. ( for user where it is coming as null, this user can't edit account name field on page).

 

Please suggest how to check the values before insert, update.

 

 

Trigger

CaseContactUpdate onCase (beforeinsert, beforeupdate) {

 

RecordType rec = [Select r.Name, r.Id FromRecordType r where r.Name='Administrative Change'];

 

for (Case newCase : Trigger.new)

{

try

{

if(newCase.RecordTypeId == rec.Id) {

System.debug(

'ushank contactId'+newCase.ContactId);

System.debug(

'ushank accountId'+newCase.AccountId);

 

if(newCase.ContactId == null){

 

Contact c1 = [Select c.Id FromContact c where c.AccountId = :newCase.AccountId and c.Primary__c = true];

newCase.ContactId = c1.Id ;

}

if(newCase.ContactId != null && newCase.AccountId != null){

 

if ([Selectcount() FromContact c where c.AccountId = :newCase.AccountId andc.Id = :newCase.ContactId] == 0){

newCase.addError(

'Selected contact does not belong to customer, please select correct contact');

}

}

}

}

catch(Exception e)

{

newCase.addError(

'Not able to save record :::'+e);

System.debug(

'Exception : '+ e);

}

}

 

}

 

Regards

I've got an SObject that is given to me by a webservice, which I have to update.

Unfortunatly, this object doesn't have an ID because the external service that made the request doesn't have it.

 

I can easily query for the ID, however the ID field is not writable, so I can't just set the sobject's ID and the do an update.

I can't just query the object, then copy over all the fields because I don't know which fields the external service wants me to update (don't want to accidently null out fields).

 

What is the best way to do an update on an object where the ID is known, but is not in the SObject itself?

Hi

 

I have been trying to use the following method doesnt work. Here is the code

 

	public static String padRight(String s, integer n) {
		
		return String.format('%1$-' + n + 's', s);  
}

 I am trying to pad my strings.

 

for example if i have two words from and yesterday, i want pad from so from would be fromxxxxx. i want the padding on every word in the list to make all the words in the string have the same characters, Like in this example from and yesterday would have the same number of characters

 

Thanks

Uves

I have a parent and child classes...i.e.,,,first and second classes..

 

in second class extends first class..

 

In the test class i create the object on second class in that i got the error like this " Error: Compile Error: Method does not exist or incorrect signature: [secondcls].add() at line 8 column 5 "

Hi All,

 

   I am  moving  tiggers from sanboz to production  account .  I  production account i have 34,240  records ,   wihile  validate the trigger in production  i am  gettting Error  like Failure Message: "System.LimitException: Too many query rows: 50001", Failure Stack Trace: "(System Code) Trigger.campMemberTrig: line 6, column 1"

 

 

 my trigger is

 

 

 

Trigger:
trigger campMemberTrig on CampaignMember (before insert, before update) {
    
 
    Map<Id, Contact> mpCon = new Map<Id, Contact>();
       list<contact> conlist=new list<contact>();
       for(Contact c: [Select id, name,email,HasOptedOutOfEmail from Contact limit 50000])----------6th line
        mpcon.put(c.id,c);
    id contactid;
     for(CampaignMember  cm:trigger.New)  {
    if(cm.status=='Opted Out'&&trigger.isinsert)
      contactid=cm.contactid; 
    else if(trigger.isupdate)
    if(trigger.oldmap.get(cm.id).status!='Opted Out'&&cm.status=='Opted Out')
    contactid=cm.contactid; 
   } 
  
    is  there any  help to  solve  this error

HI Everyone

 

As  many time i call a http webrequest before any dml operation using @future callout method.which work fine 

But how we can  call a http webrequest after the dml operation.

As i tried to call a  @future callout method after a insert but i got a callout.exception.

 

my code is as under:

 

public PageReference SendMail()
{
Request__c clFR = new Request__c ();
Request__c oldFR = [SELECT Flight_Itinerary_Name__c,Email_Bcc__c FROM  Request__c WHERE Id = :fr.Id];

 
 
clFR.Flight_Itinerary_Name__c= oldFR.Flight_Itinerary_Name__c;
clFR.Email_Bcc__c =oldFR.Email_Bcc__c 
 
insert clFR;

 WebServiceFlightReqEmail.HttpResult(clFR); // consist of http request only
}

 

 

please give me some idea to do that. 

 

Thanks in advance.

I am wondering if there is a clever way to avoid getting an error message when a query returns no results.  At the moment it throws a

 

List has no rows for assignment to SObject


This is my code:

 

public class CMPDProjectList {

    public List<CMPD_Projects__c> lstPro{get;set;}
    public List<CMPD_Projects__Share> lstProShare{get;set;}
    public List<Group> lstGroup{get;set;}
    
    public CMPDProjectList()
    {
        getGroup();
        getShare();  
        lstPro=getProlist();    
    }
    
    
     public void getGroup()
    {
        lstGroup = [Select    Group.Id,
Group.Type, Group.RelatedId From Group Where Group.RelatedId = :Userinfo.getUserRoleId() and Group.Type = 'Role']; } public void getShare() { for(Group g:lstGroup) { lstProShare = [ Select CMPD_Projects__Share.Id, CMPD_Projects__Share.ParentId, CMPD_Projects__Share.UserOrGroupId, CMPD_Projects__Share.RowCause From CMPD_Projects__Share Where CMPD_Projects__Share.UserOrGroupId = :g.Id or CMPD_Projects__Share.UserOrGroupId = :Userinfo.getUserId()]; } } public List<CMPD_Projects__c> getProlist() { CMPD_Projects__c objPro = new CMPD_Projects__c(); List<CMPD_Projects__c> lstPro = new List<CMPD_Projects__c>();
if(lstProShare.size() > 0) { for(CMPD_Projects__Share l:lstProShare) { objPro = [Select CMPD_Projects__c.Id, CMPD_Projects__c.Name, CMPD_Projects__c.Status__c, CMPD_Projects__c.Department__c, CMPD_Projects__c.Description__c, CMPD_Projects__c.OwnerId From CMPD_Projects__c Where CMPD_Projects__c.Id = : l.ParentId And CMPD_Projects__c.Status__c = 'In Progress']; lstPro.add(objPro); } } return lstPro; } }

 

I have a custom component that sits within a repeater.

the custom component's attribute is set via the repeater.

the custom component's attribute uses assignTo to set a property on its controller.

 

if (and only if) I use that attribute in the body of another custom component (inside the first custom component), then the attribute only sets the first time the repeater creates the component, never thereafter. I can access the visualforce attribute as expected... but the property on the controller is never set again.

 

I have a simple code example to illustrate the problem.

Note that the two case IDs ({!case.id} and {!myCase.id}) should be the same.

 

 

Any idea what is wrong?

 

*EDIT*

looking into it more...

the controller is being set properly, but the wrong value is being passed into the component body for some reason.

Its like {!myCase} only gets resolved once and gets reused for every repetition.

 

 

 

TestPage

<apex:page standardController="Contact">
 <apex:repeat value="{!Contact.Cases}" var="c">
   <div><c:TestComponent case="{!c}" /></div>
 </apex:repeat>
</apex:page>

 

 

TestComponent

<apex:component controller="TestComponentController">
    <apex:attribute name="case" type="Case" description="TODO" assignTo="{!myCase}"/>

    <c:TestComponent2>these should be the same: {!case.id}, {!myCase.id} </c:TestComponent2>
</apex:component>

 

TestComponentController

public class TestComponentController
{
    public Case myCase {get;set;}
}

 TestComponent2

<apex:component>
      <apex:componentbody/>
</apex:component>

 

I'm aware that when a managed package is deployed into an Org it is not possible to see log messages generated by apex code in that managed package.

 

 

However, Ideas: Display managed package logs in subscriber orgs is marked as "Delivered (Archive)".I couldn't find any documentation or direct link to what was delivered or how the issue was resolved.

 

Is there some new functionality delivered from the above idea that would allow me as the managed packaged creator to access the log messages?

Getting a very odd but consistent problem when trying to save new classes that contain an inner class (or enum) such as:

 

public class OuterClass {

    // some methods

    public class InnerClass {
        // some methods
    }
}

 

 Whether saving from the IDE or the Web interface we get the error message:

 

OuterClass: line -1, column -1: The configuration of your org has changed, please reload the page.  Missing dependent object: Type: OuterClass: InnerClass

 

If we remove all the methods of outer class and save just with the InnerClass declared the problem goes away and we can then add the methods back in and save the full class declaration.

 

 

I'm getting the following error when updating a list custom setting that's part of a managed package:

 

Update failed. First exception on row 0 with id a0DA0000007MfC9MAK; first error: FIELD_INTEGRITY_EXCEPTION, There is already an item in this list with the name

 

I've only recently started seeing this and simply cannot see how this is possible. The code is very simple, retrieve the custom setting, change a field, and then update (not insert). Nowhere am I touching the id or name of the returned object. Example:

 

MySetting__c mysetting = MySetting__c.getValues('TestName');

mysetting.MyField__c = 'test';

update mysetting;

 

Any insights as to why this would happen?

Is there a known issue (or have I missed something in the documentation) with code coverage tests and static resources?  If I try to install my managed package and *do not* check the "Ignore Apex test failures" checkbox in Step 3 of 3 the installation will fail on any unit tests that use pre-configured test data coming from static resources.

 

The test files are wrapped into the installation as static resources, and when I run the code coverage tests from within the Force.com IDE (Eclipse) and / or within the Salesforce UI (Setup > App Setup > Develop > Apex Classes > Run All Tests) everythng passes with flying colors.  But when the coverage tests are run during installation the methods that try to load the static resource files always fail.

 

The odd thing is that the methods that I'm calling for these code coverage tests (REST calls to a web service running on our servers) work fine if I use the actual URL for our REST endpoint, but if I call the same methods using a URL that points to the static resource (e.g. "/resource/12345/Namespace__MyTestFile.xml") the tests will fail.

 

To restate things slightly, just to make sure I'm explaining the problem correctly:

 

-- Code coverage tests are calling all of the same methods using an actual REST endpoint URL and a pseudo endpoint URL that points to a series of static resource URL's.  The unit tests work fine (and pass the code coverage tests during deployment) for the live URL's but fail for the static resource URL's.

 

-- Both live and static resource URL's pass the code coverage tests when I run them from within the IDE and from the Salesforce development UI's.

 

Anyone have any ideas why code coverage tests during an install would fail for static resources?  I'm pretty much stumped at this point.

 

Jerry H.

 

Hi,

 

I have a visualforce email template which is related to a custom object. In the template I have the following line where Agenda_Objective__c is a long text area.

 

 

<apex:outputText value="{!relatedTo.Agenda_Objective__c}"/>

 

 If there are any line breaks in the field in the custom object, they do not come through in the email template.

E.G. if the field contains the text:

 

Test1

Test2

Test3

 

the mail will display

 

Test1 Test2 Test3

 

Is there any way of preserving the line breaks? I could use outputfield instead of outputtext but this puts extra javascript into the mail which causes an error in my email client.

 

  • December 14, 2009
  • Like
  • 0