• Akki
  • NEWBIE
  • 0 Points
  • Member since 2010

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

Cant figure out why this code is giving me a null point exception.

 

 

trigger Account_BeforeUpdate on Account (before update)
{
    Set<String> billCountry = new Set<String>();
    
    for(Account acc : trigger.new)
      {
          billCountry.add(acc.BillingCountry);
      }
      
      Map<String, Country__c> accountMap = new Map<String, Country__c>([SELECT Region__c FROM Country__c WHERE Name IN :billCountry]);
 
      for(Account acc: trigger.new)
      {
          acc.Region__c = accountMap.get(acc.BillingCountry).Region__c;
      }
}

 

Can you spot any errors in the Code?

  • November 12, 2010
  • Like
  • 0

I'm currently designing a new customer portal and was wondering if it's possible to allow the user to upload a Document.

It would be easier if the user just get an inputFile option and the file that he selects is mailed to another person. I've got the apex and visualforce code for that setup but the file contained in the email is 0KB and there's nothing in the file.

Here's a part of my visualforce code

<apex:outputPanel id="MigrateBlock">
<apex:pageBlock title="Migrate Block" rendered="{!RenderMigrateType}">
<apex:pageBlockButtons >
<apex:commandButton action="{!SaveMigrate}" value="Migrate License"/>
</apex:pageBlockButtons>
<apex:pageBlockSection showHeader="false" columns="2" id="block76">

<apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!document.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="New Host IP Address" for="adasds"/>
          <apex:inputText value="{!HostIpAddress}" id="adasds"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>



And here's the Apex Code

public Document document
   {
   get{
   if (document == null)
        document = new Document();
   return document;
   }
   set;
}

public PageReference SaveMigrate()
{
document.FolderId = UserInfo.getUserId();
       insert document;

      document.body = null;
       document = new Document();
  if(HostIPAddress != null)
  {
  ContractAsset__c n = [SELECT id, Contract__r.id FROM ContractAsset__c WHERE Asset__r.Product2Code__c =: selectedAssets.Product2Code__c AND Contract__r.ContractNumber = :contractNumber LIMIT 1];
  Asset a = [SELECT Id from Asset WHERE Product2Code__c =: selectedAssets.Product2Code__c LIMIT 1];
  LicenseKey__c newData = new LicenseKey__c(ContractAsset__c = n.id,
  Ip_Address__c = HostIpAddress,
  LicenseType__c = 'Migrate',
  asset__c = a.id,
  Contract__c = n.Contract__r.id);
  sendEmail(); // Sends the email with a setDocumentAttachment
  insert newData;
  }

return null;

}

It's all for the Customer Portal. Any ideas how to mail the file without uploading it onto salesforce before?

  • November 08, 2010
  • Like
  • 0

'm trying to send out webcast emails to contacts when they register for a webcast on the website. The trigger looks for the country in the leads field and set's the time zone accordingly. Here's how I'm doing it

String WCTime = c.Webcast_Time__c.format('h:mm a zzzz',l.timezone__c);

where l.timezone__c can be something like this -"Asia/Calcutta" . The code get's the time correctly but doesn't take the Daylight Savings into account as I'm sending this email from UK. Is there a way to update the time taking the daylight savings into account? 

  • September 23, 2010
  • Like
  • 0

I'm trying to display some Standard object (Contracts, Products) data on the Customer portal. But as we cannot display those details directly on the customer portal, I was told that we can copy the data from that object and save it on a Custom Object and then display that.

 

But the problem is that I have contracts and products linked via a custom object already. What I want to do it first perform a query in Apex, and then save the result of that query on to a object (By save I mean copy and not save a reference) that I can then display on the customer portal.

 

I have tried using dynamic DML to do it, but then again, it wasn't working. Any other way?

  • July 20, 2010
  • Like
  • 0

Cant figure out why this code is giving me a null point exception.

 

 

trigger Account_BeforeUpdate on Account (before update)
{
    Set<String> billCountry = new Set<String>();
    
    for(Account acc : trigger.new)
      {
          billCountry.add(acc.BillingCountry);
      }
      
      Map<String, Country__c> accountMap = new Map<String, Country__c>([SELECT Region__c FROM Country__c WHERE Name IN :billCountry]);
 
      for(Account acc: trigger.new)
      {
          acc.Region__c = accountMap.get(acc.BillingCountry).Region__c;
      }
}

 

Can you spot any errors in the Code?

  • November 12, 2010
  • Like
  • 0

I'm currently designing a new customer portal and was wondering if it's possible to allow the user to upload a Document.

It would be easier if the user just get an inputFile option and the file that he selects is mailed to another person. I've got the apex and visualforce code for that setup but the file contained in the email is 0KB and there's nothing in the file.

Here's a part of my visualforce code

<apex:outputPanel id="MigrateBlock">
<apex:pageBlock title="Migrate Block" rendered="{!RenderMigrateType}">
<apex:pageBlockButtons >
<apex:commandButton action="{!SaveMigrate}" value="Migrate License"/>
</apex:pageBlockButtons>
<apex:pageBlockSection showHeader="false" columns="2" id="block76">

<apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!document.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="New Host IP Address" for="adasds"/>
          <apex:inputText value="{!HostIpAddress}" id="adasds"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>



And here's the Apex Code

public Document document
   {
   get{
   if (document == null)
        document = new Document();
   return document;
   }
   set;
}

public PageReference SaveMigrate()
{
document.FolderId = UserInfo.getUserId();
       insert document;

      document.body = null;
       document = new Document();
  if(HostIPAddress != null)
  {
  ContractAsset__c n = [SELECT id, Contract__r.id FROM ContractAsset__c WHERE Asset__r.Product2Code__c =: selectedAssets.Product2Code__c AND Contract__r.ContractNumber = :contractNumber LIMIT 1];
  Asset a = [SELECT Id from Asset WHERE Product2Code__c =: selectedAssets.Product2Code__c LIMIT 1];
  LicenseKey__c newData = new LicenseKey__c(ContractAsset__c = n.id,
  Ip_Address__c = HostIpAddress,
  LicenseType__c = 'Migrate',
  asset__c = a.id,
  Contract__c = n.Contract__r.id);
  sendEmail(); // Sends the email with a setDocumentAttachment
  insert newData;
  }

return null;

}

It's all for the Customer Portal. Any ideas how to mail the file without uploading it onto salesforce before?

  • November 08, 2010
  • Like
  • 0

'm trying to send out webcast emails to contacts when they register for a webcast on the website. The trigger looks for the country in the leads field and set's the time zone accordingly. Here's how I'm doing it

String WCTime = c.Webcast_Time__c.format('h:mm a zzzz',l.timezone__c);

where l.timezone__c can be something like this -"Asia/Calcutta" . The code get's the time correctly but doesn't take the Daylight Savings into account as I'm sending this email from UK. Is there a way to update the time taking the daylight savings into account? 

  • September 23, 2010
  • Like
  • 0

I'm trying to display some Standard object (Contracts, Products) data on the Customer portal. But as we cannot display those details directly on the customer portal, I was told that we can copy the data from that object and save it on a Custom Object and then display that.

 

But the problem is that I have contracts and products linked via a custom object already. What I want to do it first perform a query in Apex, and then save the result of that query on to a object (By save I mean copy and not save a reference) that I can then display on the customer portal.

 

I have tried using dynamic DML to do it, but then again, it wasn't working. Any other way?

  • July 20, 2010
  • Like
  • 0

Hi all,

 

I have a problem about upload file using apex:InputFile control, when i add this control (apex:InputFile) to form that uses renderer attribute, there is an error occurs:

apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute

 

Pls help me to solve this problem.