• Del_Santos
  • NEWBIE
  • 75 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 70
    Questions
  • 77
    Replies

Hi,

Please help to create a unit test for my trigger.

 

 

I having a trouble deploying my trigger in productio since sfdc is requiring a unit test. please help me. sandbox do not require a unit test. please please, im clueless onhow to start the unite tes.

 

here's the code:

=====

 

trigger UpdateQuoteManagers on Quote (before insert, before update) {
Set<ID> idOwners = new Set<ID>();


for(Quote quotes:trigger.new)
{
idOwners.add(quotes.Account_Manager__c);
}

if (idOwners.size() > 0)
{
Map<Id,User> users= new Map<Id,User>([Select Territory_Head__c, District_Head__c from User where Id in : idOwners]);

for(Quote qu:trigger.new)
{

if (users.get(qu.Account_Manager__c).Id!= null)
{
qu.District_Head2__c = users.get(qu.Account_Manager__c).District_Head__c;
qu.Territory_Head2__c = users.get(qu.Account_Manager__c).Territory_Head__c;
}
else
{
qu.District_Head2__c = null;
qu.Territory_Head2__c = null;

}
}
}
}

Hi,

 

Can anyone tell me how can i create validation on leads' attachment? 

I have a requirement wherein there should be an attachment before i convert a lead to account.

 

 

Appreciate help. thanks. :))

 

Del

Hi,

 

I have a custom button with below javascript, however it is prompting me error: "Yes is not defined"

please help.

 

===============

 

if( {!Quote.With_Concesssion__c} == "Yes" ) 

window.open('http://www.yahoo.com'); 

else 

window.open('http://www.google.com'); 
}

 

 

 

Thanks,

Del

Hi,

 

I created a javascript button to open a vf page if {!Quote.Installation_Address_2__c} is not blank but encountering an error. Im not sure how to define a blank value. i am encountering an invalid token issue.

 

 

==========================================

here's the code

 

if ({!Quote.Installation_Address_2__c}!= null)
{
window.parent.location.href="apex/Generate_Endorsement_Letter_B?id={!Quote.Id}";
}
else {
alert("Site B Installation Address is Missing!");
}

 

Thanks!

Del

Hi Guys,

 

1. I have a record type and page layout called "locked Opportunity"

2. I just created a new opportunity record type "BellTel Opportunity"  and a new page layout also called "BellTel Opportunity" 

3. We have a separate system called FIS integrated with Salesforce to update some opportunity field. This system is designed to verify if the facility for the created opportunity is available.

4. We have a custom button that will send the opportunity details to FIS.

5. Exchange of information from SFDC and FIS is thru WSDL.

 

 

 

Now, I created a new opportunity with thisrecord type "BellTel Opportunity", when i send the details to FIS the opportunity record and layout is still "BellTel Opportunity". But when FIS returns the details to salesforce, it does not only update the fields but i also changed the record type and layout to "locked Opportunity". I am struggling all day to find out why it was changing the record type. Could someone help me or give me a clue.

 

 

Im totally clueless.:(

 

 

Thanks,

Del

 

 

Hi Guys,

 

Can someone help me. I have a visualforce page with a couple of fields and validations, I have a requirement that when a checkbox A is ticked, field C will be disabled and will copy the value entered on from field B. So for that, I am using below JS and  it is working quiet ok, however during the page refresh the functionality is lost. Field C will be blank and enabled.

 

Could someone please help.. :(

 

 

<script language="javascript">
            function ToggleInput(copyid,billhouseid,billaptid,insthouseid,instaptid)
            {
                var copy = document.getElementById(copyid);
                var billhouse = document.getElementById(billhouseid);
                var billapt = document.getElementById(billaptid);
                var insthouse = document.getElementById(insthouseid);
                var instapt = document.getElementById(instaptid);


              
                if(copy.checked == true)
                {
                    billhouse.disabled = true;
                    billhouse.value = insthouse.value;
                    billapt.disabled = true;
                    billapt.value = instapt.value;
                }
                else
                {
                    billhouse.disabled = false;
                    billapt.disabled = false;
                }
            }
           
               
        </script>
       

        <apex:inputText value="{!Lead.Installation_House__c}" required="true" id="insthouse"/>
        <apex:inputText value="{!Lead.Installation_Apartment__c}" required="true" id="instapt"/>
        <apex:inputCheckbox id="copy" value="{!Lead.Copy__c}" onchange="ToggleInput('{!$Component.copy}','{!$Component.billhouse}','{!$Component.billapt}','{!$Component.insthouse}','{!$Component.instapt}');"/>
        <apex:inputText id="billhouse" value="{!Lead.Billing_House__c}"/>
        <apex:inputText id="billapt" value="{!Lead.Billing_Apartment__c}"/>

 

 

Thanks,

Del

Hi Guys,

I have this code that should disable a two fields, the phone and the fax. However, only the phone is getting disabled when i click the checkbox. Could someone help me with this? thanks!

 

Regards,

Del

 

 

==============================

<script language="javascript">
            function ToggleInput(theId)
            {
                var e = document.getElementById(theId);

                if(e != null)
                {
                    e.disabled = (e.disabled ? false : "disabled");
                }
            }

            window.onload = function () { document.getElementById('{!$Component.phone}','{!$Component.fax}').enabled= "enabled"; }

        </script>
        <apex:inputCheckbox onchange="ToggleInput('{!$Component.phone}','{!$Component.fax}');" value="{!Lead.Copy__c}"/>
        <apex:inputText id="phone" value="{!Lead.phone}"/>
        <apex:inputText id="fax" value="{!Lead.fax}"/>

Hi Guys,

 

I am deploying  below trigger in our production but im always getting "Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required". This is my first time creating a trigger could someone help me please.

 

trigger twebLead on Lead (after update) {
   if (Trigger.new.size() == 1) {
     if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
      if (Trigger.new[0].ConvertedAccountId != null) { 
        Account a = [Select a.Id, a.CurrencyIsoCode From Account a Where a.Id = :Trigger.new[0].ConvertedAccountId];
        a.CurrencyIsoCode = 'PHP';
        update a;
      }
     
      if (Trigger.new[0].ConvertedOpportunityId != null) {
        Opportunity o = [Select o.Id, o.CurrencyIsoCode from Opportunity o Where o.Id = :Trigger.new[0].ConvertedOpportunityId];
        o.CurrencyIsoCode = 'PHP';
        update o;
      }
    }
  }
}

 

I don't know what i am missing since i have deployed the same code in sandbox and worked well.

 

Thanks,

Del

Hi Guys,

 

Below is the code for attaching a file in a record. I want to create a validation rule so that user can only upload jpeg files. Is there a way to do this? please help.

 

Thanks,

Del

 

 

 

public with sharing class AttachmentUploadController {
 
  public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }
 
  public PageReference upload() {
 
    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = '001W0000005v6Ih'; // the record the file is attached to
    attachment.IsPrivate = true;
 
    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }
 
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
 
}

Was wondering if someone has successfully accomplished cloning a quote and the related quote line items?  I need it to create a new quote revision without creating a whole new quote with new quote number...just a new revision number.

 

I am struggling and thought that this task has probaly been done by someone "out there"...

 

I appreciate your help!!