• MoUsman
  • NEWBIE
  • 260 Points
  • Member since 2012
  • Salesforce Technical Consultant


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

Hey all I am having a hard time trying to figure out the count of the number of child records in my Parent Record and displaying it in my Visualforce.

 

Here is my current Query

 

public class myController{

public List <account> accList {get;set;}
public myController {

accList = [select id, Name, (Select id, Name from Addresses__r) from Account];


}

And my visualforce Page will look like this

<apex: repeat value="{!accList}" var="a">
ID: {!a.Id}
Name: {!a.Name}
Number of Child Records: {!getCountChild}
<apex:repeat value="{!a.Addresses__r}" var="add">
Address info id: {!add.Id}
Address Name: {!add.Name}

</apex:repeat>
</apex:repeat>

 Any help would be great on this, I've been stuck on this for weeks.

 

Thanks

Hi ,

 

Can I get property into my contructor   ? 

 

For example if I have a private list of Contacts and can I use getter methods into my contructor ?

 

The code below does not work

 

public class ExtContact {
    
    private list<contact> lstcontact;            
    
    public ExtContact(ApexPages.StandardController controller) {
          
          public list<contact> getlstcontact(){
                lstcontact=[select id,firstName,lastName from contact LIMIT 10];
                return lstcontact;
           }
    }

}

 

 

Please suggest,

 

Regards,

Sane

 

  • March 21, 2013
  • Like
  • 0

So I've gotten pretty good at writing triggers, by simply altering coding I've found on here and salesforce.com. So I understand how to write them, but not necessarily WHY they work. So because I'm a novice, I'm having a bit of trouble figuring out the test codes. I've read the Introduction to Apex Test Methods, but it's not quite clicking for me. I'm hoping this is a really easy trigger that someone can help me figure out how to write the test code for it? If it isn't too much work to write it for me, I can probably figure out all of the other triggers.

 

trigger AutoCreateGeneralIntake on Contact (after insert) {
    List<General_Intakes__c> GeneralIntake = new List<General_Intakes__c>();

    
    for (Contact newContact: Trigger.New) {
        if (newContact.Screening_ID__c != null) {
            GeneralIntake.add(new General_Intakes__c(
                        Name = '1',
                        Primary_Contact__c = newContact.ID,
                        Screening_ID__c = newContact.Screening_ID__c,
                        Primary_Household_ID__c = newContact.Household_ID_del__c));
        }
    }
    insert GeneralIntake;
}

 Thank you in advance for any help.

Is there an option that can be sent to send the welcome email to a user when creating the user through apex?

I'm able to create the user successfully, just can't find any option to send the welcome email.

 

Thanks!

Hi

 

I have an inline visualforce added to my standard contact page. All works fine but the field font doesn't match with the standard salesforce style.

Could anybody please tell me what style should be added for this to be achieved

 

<apex:page standardController="Contact" extensions="contactSubRecords" tabstyle="Contact" showheader="true">

<apex:pageBlock >
<apex:pageblockSection title="Alumnus"  columns="1" rendered="{!if(contact.Alumnus__c==True,true,false)}">
<apex:tabPanel switchType="client" value="{!selectedTab}" tabClass="activeTab" inactiveTabClass="inactiveTab" >
<apex:tab label="Alumnus"  > 
  <apex:pageBlock >
   <apex:pageBlockSection title="Alumnus Details">
			<apex:outputField value={!Contact.field1__c}" />
			<apex:outputField value="{!Contact.field2__c}" />
   </apex:pageBlockSection>
 </apex:pageBlock> 
</apex:tab>
</apex:tabPanel>
</apex:pageblockSection>
</apex:pageBlock>
<apex:page>

 

I have an sObject with a decimal field that I'm having problems creating an APEX loop that will sum the values contained in the instances of that field. The code for it is nested inside another loop. Below is some psuedo code for what's relevent.

 

Initially, before any of the loops, I created a List called Brn_Hrs. Beginning at (3) below, you'll see there's a query done to create a Temp list of records. After that, I set Brn_Hrs[0].Hours__c to (0.00) because I only want a total or sum as output from the loop. I also do not want to fill each element of the array as it goes through each iteration of the loop; both this one and the larger one it's nested inside of.

 

Finally we come to the new for loop I'm having difficulty with when we reach (4). 

 

List<Time__c> Brn_Hrs;
// (3) Create Temp list of Hours records called "BrnH_Tmp" List<Time__c> BrnH_Tmp = [SELECT Hours__c FROM Time__c WHERE Time__c.Resource__c = :rTime.Resource__c AND Time__c.OppLnk__c = :rTime.OppLnk__c]; // Below need to be reset to zero for each iteration of larger loop Brn_Hrs[0].Hours__c = (0.00); count = 0; // (4) Sum Total Burnt Hours for this combo do { Brn_Hrs[0].Hours__c += BrnH_Tmp.Hours__c ; }while (count < BrnH_Tmp.size);

 

As I understand it, I can't do the "+=" operation between a Decimal Variable and BrnH_Tmp because the latter is an sObject; thus the reason I specified the Brn_Hrs[0].Hours__c. Should I have instead specified Brn_Hrs[0].Hours__c[0] in order to make this approach work or do I need to use a "get" operation of some kind on BrnH_Tmp to sum all the instances of Hours__c in the BrnH_Tmp, perhaps by putting them into another variable? Or perhaps do I need to do something like use the "VALUE" operator on the sObject instead?

 

I'm still trying to learn how to use APEX's implicit FOR and DO-WHILE loops as opposed to the "for(i=0; i<j; i++)" type of syntax where I can also put "i" into the sObject's array name inside of brackets like what can be done with a specific value. I'm finding that quite frustrating in situations like this.

 

Any help to point me in the right direction would be most appreciated. :)

 

 - pixel

 

  • November 07, 2012
  • Like
  • 0

sobject method ,clone(),has four parameters,the first " opt_preserve_id" argument
determines whether the ID of the originalobject is preserved or cleared in the duplicate.
If set to true, the ID is copied to theduplicate. The default is false, that is, the IDis cleared.apex api document .
when i set ,clone(true);it does not work .page is showed:account id can not be inserted.


 Savepoint sp = Database.setSavepoint();
         account newacc;
 
         try {
 
              //copy the purchase order - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             acc = [select Id, Name from account where id = :acc.id];
             newacc = acc.clone(true);
             insert newacc;
 
             // set the id of the new acc created for testing
               newRecordId = newacc.id;
 
             // copy over the line cons - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<Contact> cons = new List<Contact>();
             for (Contact con : [Select c.Id,c.Name From Contact c where accountid = :acc.id]) {
                  Contact newcon = con.clone(true);
                  newcon.accountid = newacc.id;
                  cons.add(newcon);
             }
             insert cons;
 
         } catch (Exception e){
             // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
         }

 

hi guys,did u meet the case?

Thanks!


  • October 30, 2012
  • Like
  • 0

Does anyone know of an example of code using Account's geolocation based on the billing address. I am finding several examples of applications mapping the account, but I am not finding a tool to populate the account's geolocation (longitude and latitude). Does anyone have any examples I can use?

 

Thanks,

I have a data table of date fields, I need to be able to have a field at the top not in the table where i can change the date and click copy and it copies to all in that one column. I have tried java script with no luck.. I am just hard coding the date now, i can figure out the input field, I just need to know how to copy it to that first column...

 

<apex:page Controller="RenewalController" tabStyle="Entities__c" sidebar="false">
  <apex:form >
    <apex:pageBlock title="Entity" mode="edit" id="ent">
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
        <apex:commandLink onclick="return CopyShipInfo()" value="CopyTo Renewal Due Date" reRender="ent"/>
      </apex:pageBlockButtons>
      
      <apex:dataTable value="{!myList}" var="opp" id="ents">
      <apex:column headerValue="Entity">{!opp.Name}&nbsp;</apex:column>
        <apex:column headerValue="Renewal Due Date">
        <apex:inputField value="{!opp.State_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="Renewal Received">
        <apex:inputField value="{!opp.Renewal_Received_From_State__c}" id="renew"/>
        </apex:column>
        <apex:column headerValue="Printed Renewal">
         <apex:inputField value="{!opp.Renewal_Printed__c}"/>
        </apex:column>
        <apex:column headerValue="Emailed Renewal">
        <apex:inputField value="{!opp.Renewal_Emailed__c}"/>
        </apex:column>
        <apex:column headerValue="Rec Pay For Renewal">
        <apex:inputField value="{!opp.Received_Payment_For_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="List Filed With State">
        <apex:inputField value="{!opp.List_Filed_with_State__c}"/>
        </apex:column>
        <apex:column headerValue="Stamped List Received">
        <apex:inputField value="{!opp.Stamped_List_Received_from_State__c}"/>
        </apex:column>
        <apex:column headerValue="Packet Sent">
       <apex:inputField value="{!opp.Packet_Sent__c}"/>
        </apex:column>
      </apex:dataTable>
     
     
         <script>
          function CopyShipInfo()
          {
            document.getElementById('{!$Component.ents.renew}').value = '01/01/1976';
        </script>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

Hi,

I have an ApiName and value pair in String form like given below. 

 

String fieldvalpair='Name=Aig Sun america,Lead_Status__c=Contacted,Lead_Source__c=Inhouse';

 

 

Prospect pros=new Prospect(id='a0YQ0000003YLph');

 


I want to update record pros,how can i do that?

 

thanks!

We are developing a Salesforce Offline App for iOS using Ratchet(Front End) and Cordova, encountering an issue where we are not able to identify the session expiration time and due to this reason App get logout automatically and soup data (Smartstore) get deleted, Is someone faced similar issue ever? if yes, please share your experience,  solution or workaround you did to get  this resolve.  It would be great help!
Here is the SDK version and other Information we already tried.
  • We are using SalesforceMobile SDK 4.1.0
  • Already Tried with Session Settings (Setup > Security Controls > Session Settings) which does affect  the session time of the App even we do not know exact time of the expiration, sometime it get expired within 24 hours sometime takes more than that
  • September 02, 2016
  • Like
  • 0
Me and my colleague are working on a Conrova/Polymer project for iOS and Andoid, She is using xcode and I am using Android Studio platform, when she export her running code for Android studio it is not working on my platform it is throwing  the following error:

"06-14 06:50:37.360 6217-6217/com.mobileuielements I/chromium: [INFO:CONSOLE(59)] "Uncaught module com.salesforce.util.bootstrap not found", source: file:///android_asset/www/cordova.js (59)
06-14 06:50:37.360 6217-6217/com.mobileuielements I/chromium: [INFO:CONSOLE(2049)] "Uncaught module com.salesforce.util.bootstrap not found", source: polymer.html"

Need a hand, Any help appreciated. Thanks In Advance!
Me and my colleague are working on a Conrova/Polymer project for iOS and Andoid, She is using xcode and I am using Android Studio platform, when she export her running code for Android studio it is not working on my platform it is throwing  the following error:

"06-14 06:50:37.360 6217-6217/com.mobileuielements I/chromium: [INFO:CONSOLE(59)] "Uncaught module com.salesforce.util.bootstrap not found", source: file:///android_asset/www/cordova.js (59)
06-14 06:50:37.360 6217-6217/com.mobileuielements I/chromium: [INFO:CONSOLE(2049)] "Uncaught module com.salesforce.util.bootstrap not found", source: polymer.html"

Need a hand, Any help appreciated. Thanks In Advance!
Can anybody share the C# bulk (query, insert, update, delete) api examples. Online i can find Java exaples, but not C#.

-Sid

Hi,

 

Am new to sales force test class writing test class for displaying records when contacts have any

cases showing error message how to cover these method in test class

==My method===

 

public void delete()
{
conrecords=true;
viewpanel=false;
editpanel=false;

id aid=apexpages.currentpage().getparameters().get('conname');
con=[select id,lastname, Accountid, name,phone,email,(select id, CaseNumber from cases) from contact where id=:aid];
if(con.cases.size()>0 )
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Fatal, 'You donot delete this record. It related to cases or customerportal contact');
ApexPages.addMessage(myMsg);
}

}

 

Bold font code covered but how to cover if condition Any one can solve my issue?

 

 

Thanks in Advance.

Hello All,

I would like to know wether it's possible to display some status loading, such as actionStatus, that trigger by a commandButton.

The only requirement (I'm trying to to simplify our problem) is that we MUST OMIT the reRender attribute from the commandButton.

 

So basically, we're trying to do something like that - 

<apex:commandButton value="Test" action="{!testAction}" status="testStatus" /> 

 

Unfortunately, it seems that it's not possible to use actionStatus without the reRender attribute.

 

Any suggestions?

 

Thanks a lot,

 

 

 

 

  • March 30, 2013
  • Like
  • 0

Hey all I am having a hard time trying to figure out the count of the number of child records in my Parent Record and displaying it in my Visualforce.

 

Here is my current Query

 

public class myController{

public List <account> accList {get;set;}
public myController {

accList = [select id, Name, (Select id, Name from Addresses__r) from Account];


}

And my visualforce Page will look like this

<apex: repeat value="{!accList}" var="a">
ID: {!a.Id}
Name: {!a.Name}
Number of Child Records: {!getCountChild}
<apex:repeat value="{!a.Addresses__r}" var="add">
Address info id: {!add.Id}
Address Name: {!add.Name}

</apex:repeat>
</apex:repeat>

 Any help would be great on this, I've been stuck on this for weeks.

 

Thanks

We are trying to assign a user name to a custom field (Assigned_To__c) that is in the standard case object through a trigger along with some other critera - everything is working except for the Assigned To where it is dumping the following error:

 

Save error: Illegal assignment from LIST<User> to Id

Here is the code:

 

if (newCase.Subject=='RS DB Stats') {
                    newCase.Type='RS DB Stats';
                    newCase.Reason='Other';
                    newCase.Assigned_To__c=[select Name from User where Name='Nick Koszykowski'];
                    newCase.Status='Closed';
                }

 

Any thoughts on what we've done wrong?

Hi ,

 

Can I get property into my contructor   ? 

 

For example if I have a private list of Contacts and can I use getter methods into my contructor ?

 

The code below does not work

 

public class ExtContact {
    
    private list<contact> lstcontact;            
    
    public ExtContact(ApexPages.StandardController controller) {
          
          public list<contact> getlstcontact(){
                lstcontact=[select id,firstName,lastName from contact LIMIT 10];
                return lstcontact;
           }
    }

}

 

 

Please suggest,

 

Regards,

Sane

 

  • March 21, 2013
  • Like
  • 0

Hi Community,

 

I have custom button on std Obj detail page when i click it the script behind the sceens will run and popup a modal dialog .

 

in the modal dialog i am displaying a vf page. The values in the vf Page will display based on the 3 parameters in the url.

 

So i want the syntax for the the following line.

 

var iframe_url='{URLFOR("/apex/VFpagename?scontrolcatching=1&id='{sObj.Id}&Name='{!sObj.Name}'")}

 

I tried different other ways but i did not get through. Any help or suggestions appriciated.

 

Thanks,

 

Hi Guys,

     The code is done for the google map using visualforce page and assigned to the page layout. Not the all is showing any

     error. But even not showing the map in the following accounts. I don't know in which setting its not allowing me not to cross  

     the barrier to display it on accounts.

 

     Can anyone help me on this.

 

 

Regards