• MsKnight
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 12
    Replies
Hi,

I'm trying to create a VF page that will display a budget line items in an easily editable format. So far I have been able to display both the budget information at the top of the page and the associated line items below in a pageBlockTable.

Code:
<apex:page Standardcontroller="Budget__c">
<apex:detail relatedList="false"/>
   <apex:pageBlock title="Budget Line Items">
       <apex:pageBlockTable value="{!Budget__c.BudgetLine__r}" var="lineItem">
        <apex:column value="{!lineItem.Name}"/>
        <apex:column value="{!lineItem.Cost_Code__c}"/>
        <apex:column value="{!lineItem.Category__c}"/>
        <apex:column value="{!lineItem.Sales_Budget__c}" />
        <apex:column value="{!lineItem.PM_Initial_Projection__c}"/>
        <apex:column value="{!lineItem.Active_Budget__c}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

 I want the end user to be able to double click on a field in the "Budget Line Items" table, edit it and then have the field save (similar functionality to the Enhanced List View). I've been digging through the documentation and haven't found the best way of going about this. Any suggestions on implementing ondblclick or onRowclick for a table?


Thanks!

Before the Summer '08 release we created a custom list button that executes Javascript and calls an Apex class. It was working perfectly until we turned on the enhanced list view. Below is the code and the error:


Code:
{!REQUIRESCRIPT("/soap/ajax/11.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/11.0/apex.js")}

var errnum = 0;
var errmsg = "";

var idArray = {!GETRECORDIDS($ObjectType.SFDC_Purchase_Requisition__c)};

if (idArray[0] != null) {
var records = sforce.connection.retrieve("Name,Purchase_Order__c", "SFDC_Purchase_Requisition__c", [idArray]);
if (records.length > 0) {
for (var i = 0; i < records.length; i++) {
if (records[i].SFDC_Purchase_Order__c != null) {
errnum++;
errmsg += records[i].Name + "\n";
}
}
if (errnum == 0) {
var result = sforce.apex.execute("POButton", "createPO", {
reqsId: idArray
});
alert("PO Created!");
window.parent.location.href = "/" + result[0];
}
else {
alert("A PO already exists for: \n" + errmsg);
}
}
}
else {
alert("Please select at least one record.");
}

 
Code:
{faultcode:'sf:MALFORMED_ID', faultstring:'MALFORMED_ID: bad id function (B){
 var A = this.indexOf(B);
 if(A != -1) {
    this.splice(A,1);
 }
 return this;
}

 
I have narrowed it down to the point where it tries to retrieve the Name and Purchase_Order__c from the records. I haven't been able to find any documentation on this function changing. Any thoughts?

Thanks!






Message Edited by MsKnight on 06-16-2008 03:57 PM
Pre-Summer '08 we created code in Apex to send an email triggered on an update of a custom object. On Thrusday (6/5) and Friday (6/6) it was working fine. Since Monday all our testing shows that it updates, sends the email and then reverts back to previous values.

Code:
SendEmail.addSendEmail('Accounts Receivable','Roof Mounts In', p.Id);


 public static void addSendEmail(String role,String templateName,String whatId){
 
 UserRole[] roleid = [SELECT Id FROM UserRole WHERE Name = :role];
 User[] user = [SELECT Email FROM User WHERE UserRoleId = :roleid[0].Id]; 
 Contact[] contact = [SELECT Id FROM contact WHERE Name = 'System User'];
 EmailTemplate[] template = [SELECT Id FROM EmailTemplate WHERE Name = :templateName];
  
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {user[0].Email};
      mail.setToAddresses(toAddresses);
      
    mail.setSaveAsActivity(false);
    mail.setTargetObjectId(contact[0].Id);
    mail.setWhatId(whatId);
    mail.setTemplateID(template[0].Id);
    
    // Send the email you have created.
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 }

 I have reviewed the Pre-Release notes and can't find anything that would have impacted our code. Please let me know if you have any suggestions!


Thanks

Hi,

I recently implemented a new object (Forms) in Salesforce that contains a lookup to another custom object (Items). When my users go to fill in a new Form, they are required to lookup an Item. Since the users have neither viewed  Items before nor created Items, the initial lookup lists no Items. I know that lookups generally show the last 20 items a user edited or created - is there any way around this? I want them to see all Items available.


Thanks!
Hello,

I'm sending an email based on a template that has merge fields from several different objects. I am using a template that has merge fields from both our Project (p) object and our Permit (permit) object. I am currently using "mail.setWhatId(p.Id);" which returns an email with the project merge fields filled and the permit merge fields blank. I am aware that there is a function setWhatIds, but I cannot figure out how to enter both the project Id (p.Id) and the permit Id (permit.Id). I have tried all of the following variations with no success:

mail.setWhatIds(p.Id, permit.Id);
mail.setWhatIds(p.Id permit.Id);
mail.setWhatIds(p.Id; permit.Id);

What is the proper way to enter mulitple IDs?


Thanks!

Hi,

I'm trying to write a Test Method for a class that sends an email. I'm stuck at 73% - I can cover the addRoofMountsCheck, but can't get coverage on lines 8-18 (all of the code for sending the email). Any suggestions?

Code:
public class RoofMountsIn {
    public static void addRoofMountsCheck(SFDC_Project__c[] pros) {
       for (SFDC_Project__c p:pros) {
            if (p.Roof_Mounts_In__c != True){
                p.Roof_Mounts_In__c = True;
       
           for (User user : [SELECT Email FROM user WHERE UserRoleId = 'userId']){               
                 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses = new String[] {user.Email};
                  mail.setToAddresses(toAddresses);

                mail.setSaveAsActivity(false);
                mail.setTargetObjectId('contactId');
                mail.setWhatId(p.Id);
                mail.setTemplateID('emailtemplateId');
               
        // Send the email you have created.
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                       }
                }
           }
    }
}

 
Thanks!

Hi,

Is there any reason that the setWhatId function can only be used when setTargetObjectId is a contact? I am building an email notice around a template and I want to send it to a user. Without the setWhatId, none of the merge fields pull through. Is there a work around that I am not aware of?


Thanks!


Hi,

Is possible to trigger a workflow alert and/or task using Apex?


Thanks!




Message Edited by MsKnight on 03-13-2008 04:14 PM
Code:
<apex:page Controller="DoctorContact">
    <apex:form >

       <apex:pageBlock title="New Contact"  mode="Edit" >
                <apex:pageBlockButtons >
                               <apex:commandButton action="{!save}" value="Save"/>
                               <apex:commandButton action="{!Leave}" value="Cancel" immediate="true"/>
                </apex:pageBlockButtons>
        <apex:pageBlockSection title="New Contact" columns="2" >
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Name" for="Name"/>
                   <apex:inputfield value="{!DoctorContact.Name}" id="Name"  required="true" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Doctor2" for="doctor"/>
                   <apex:inputfield value="{!DoctorContact.Account__c}" id="doctor"  required="true"  />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Phone" for="Phone"/>
                   <apex:inputfield value="{!DoctorContact.Phone__c}" id="Phone"   />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Fax" for="Fax"/>
                   <apex:inputfield value="{!DoctorContact.Fax__c}" id="Fax"   />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Contact Type" for="ContactType"/>
                   <apex:inputfield value="{!DoctorContact.Contact_Type__c}" id="ContactType"   />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Notes" for="Notes"/>
                   <apex:inputfield value="{!DoctorContact.Notes__c}" id="Notes"   />
            </apex:pageBlockSectionItem>
           
            
        </apex:pageBlockSection>
                           
        </apex:pageBlock>
    </apex:form >

</apex:page>

 
 
I have a phone field that needs validation at the save.  The VF page is sending it to the object but it's not be caught and attached to the field on the page.  Example above. How do i connect the validation to the field on my VF page?
  • October 13, 2008
  • Like
  • 0
Before the Summer '08 release we created a custom list button that executes Javascript and calls an Apex class. It was working perfectly until we turned on the enhanced list view. Below is the code and the error:


Code:
{!REQUIRESCRIPT("/soap/ajax/11.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/11.0/apex.js")}

var errnum = 0;
var errmsg = "";

var idArray = {!GETRECORDIDS($ObjectType.SFDC_Purchase_Requisition__c)};

if (idArray[0] != null) {
var records = sforce.connection.retrieve("Name,Purchase_Order__c", "SFDC_Purchase_Requisition__c", [idArray]);
if (records.length > 0) {
for (var i = 0; i < records.length; i++) {
if (records[i].SFDC_Purchase_Order__c != null) {
errnum++;
errmsg += records[i].Name + "\n";
}
}
if (errnum == 0) {
var result = sforce.apex.execute("POButton", "createPO", {
reqsId: idArray
});
alert("PO Created!");
window.parent.location.href = "/" + result[0];
}
else {
alert("A PO already exists for: \n" + errmsg);
}
}
}
else {
alert("Please select at least one record.");
}

 
Code:
{faultcode:'sf:MALFORMED_ID', faultstring:'MALFORMED_ID: bad id function (B){
 var A = this.indexOf(B);
 if(A != -1) {
    this.splice(A,1);
 }
 return this;
}

 
I have narrowed it down to the point where it tries to retrieve the Name and Purchase_Order__c from the records. I haven't been able to find any documentation on this function changing. Any thoughts?

Thanks!






Message Edited by MsKnight on 06-16-2008 03:57 PM
Pre-Summer '08 we created code in Apex to send an email triggered on an update of a custom object. On Thrusday (6/5) and Friday (6/6) it was working fine. Since Monday all our testing shows that it updates, sends the email and then reverts back to previous values.

Code:
SendEmail.addSendEmail('Accounts Receivable','Roof Mounts In', p.Id);


 public static void addSendEmail(String role,String templateName,String whatId){
 
 UserRole[] roleid = [SELECT Id FROM UserRole WHERE Name = :role];
 User[] user = [SELECT Email FROM User WHERE UserRoleId = :roleid[0].Id]; 
 Contact[] contact = [SELECT Id FROM contact WHERE Name = 'System User'];
 EmailTemplate[] template = [SELECT Id FROM EmailTemplate WHERE Name = :templateName];
  
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {user[0].Email};
      mail.setToAddresses(toAddresses);
      
    mail.setSaveAsActivity(false);
    mail.setTargetObjectId(contact[0].Id);
    mail.setWhatId(whatId);
    mail.setTemplateID(template[0].Id);
    
    // Send the email you have created.
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 }

 I have reviewed the Pre-Release notes and can't find anything that would have impacted our code. Please let me know if you have any suggestions!


Thanks

Hi,

I recently implemented a new object (Forms) in Salesforce that contains a lookup to another custom object (Items). When my users go to fill in a new Form, they are required to lookup an Item. Since the users have neither viewed  Items before nor created Items, the initial lookup lists no Items. I know that lookups generally show the last 20 items a user edited or created - is there any way around this? I want them to see all Items available.


Thanks!
Hi,

I'm trying to write a Test Method for a class that sends an email. I'm stuck at 73% - I can cover the addRoofMountsCheck, but can't get coverage on lines 8-18 (all of the code for sending the email). Any suggestions?

Code:
public class RoofMountsIn {
    public static void addRoofMountsCheck(SFDC_Project__c[] pros) {
       for (SFDC_Project__c p:pros) {
            if (p.Roof_Mounts_In__c != True){
                p.Roof_Mounts_In__c = True;
       
           for (User user : [SELECT Email FROM user WHERE UserRoleId = 'userId']){               
                 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses = new String[] {user.Email};
                  mail.setToAddresses(toAddresses);

                mail.setSaveAsActivity(false);
                mail.setTargetObjectId('contactId');
                mail.setWhatId(p.Id);
                mail.setTemplateID('emailtemplateId');
               
        // Send the email you have created.
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                       }
                }
           }
    }
}

 
Thanks!

Hi,

Is there any reason that the setWhatId function can only be used when setTargetObjectId is a contact? I am building an email notice around a template and I want to send it to a user. Without the setWhatId, none of the merge fields pull through. Is there a work around that I am not aware of?


Thanks!


Hi,

Is possible to trigger a workflow alert and/or task using Apex?


Thanks!




Message Edited by MsKnight on 03-13-2008 04:14 PM