• Rolando Esteves
  • NEWBIE
  • 75 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 30
    Replies

 

I was able to upload records into objects with a custom code in apex. My only problem is that the split function does not care about text delimiters. Is there any possible way to be able to split without afecting fields with commas inside a text delimiter.

 

Example : "DOG HAS , A HOUSE"

 

Example Code:

 

          String FileData = FileRecords.toString();
           FileData = FileData.replace('"', '');
     
           if(FileData <> NULL)
           {
              LineNo = FileData.split('\n');

 

Whats the best way to develop a Andriod App for Salesforce. (Must have offline mode and Digital Signature)

 

Thanks for all the answers.

Hi,

 

I'm currently trying to upload a 950x 250 image on this field. Salesforce auto sizes the image to a smaller one and I have to drag the image in order to obtain the original size of it.

 

Is there a way to fix this or sis it a bug in salesforce?

 

 

Thanks in Advance

Hi,

 

I have a string field on the opportunity object that I am trying to update with the salesforce Enterprise API. My opportunity is Closed Won. For some reason I do not see the update on the field.

 

Heres my VB Code:

 

    Private Sub queryProject()

        Dim oppProjectQuery As String
        Dim cnct As String

        oppProjectQuery = "Select B.AccountId, B.OpportunityID__c, B.Name, B.CloseDate, B.Account_Manager_Name__c, B.Sales_Location2__c, B.PO__c, Amount, B.Total_Opp_Profit_Amount__c, B.Total_Quantity__c, B.TaxAmount__c From Opportunity B "
        oppProjectQuery = oppProjectQuery & " WHERE B.StageName = 'Closed Won' AND B.TransferContract2GP__c = false"
        'get a list of acctIds


        Dim a_Opp(0) As netxarEE.sObject
        'Sql(Connection & Statements)
        Try
            con.ConnectionString = constr
            con.Open()
        Catch ex As Exception
            MsgBox("Error while establishing connection..." & ex.Message & "Insert Records")
        End Try

        Try
            'get a list of oppLineItems
            Dim oppQR As QueryResult = Nothing
            oppQR = binding.query(oppProjectQuery)
            For i As Integer = 0 To oppQR.records.Length - 1
                Dim opp As Opportunity = oppQR.records(i)
                Dim insProjectQuery As String

                'Obtaining Contact Name
                Dim contactName As String
                cnct = "SELECT A.NAME FROM CONTACT A "
                cnct = cnct & " Where A.AccountId IN ('" & opp.AccountId & "') LIMIT 1"
                Dim contacto As QueryResult = Nothing
                contacto = binding.query(cnct)
                Dim cnt As Contact = contacto.records(i)
                contactName = cnt.Name

                'Obtaining Customer Number
                Dim custNum As String
                custNum = "SELECT A.Customer_ID__c FROM Account A "
                custNum = custNum & " Where A.Id IN ('" & opp.AccountId & "') LIMIT 1"
                Dim customer As QueryResult = Nothing
                customer = binding.query(custNum)
                Dim cus As Account = customer.records(i)
                custNum = cus.Customer_ID__c

                'Forming Insert Query in order Fill PROJECTQTBLE
                insProjectQuery = "INSERT INTO PROJECTQTBL VALUES ('"
                insProjectQuery = insProjectQuery & custNum & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.OpportunityID__c & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.OpportunityID__c & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.Name & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.CloseDate & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.CloseDate & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.Total_Quantity__c & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.Amount & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.Total_Opp_Profit_Amount__c & "'" & ","
                insProjectQuery = insProjectQuery & "'" & contactName & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.Sales_Location2__c & "'" & ","
                insProjectQuery = insProjectQuery & "'" & opp.TaxAmount__c & "'" & ","
                insProjectQuery = insProjectQuery & "'" & uFlag & "'" & ")"
                cmd = New SqlCommand(insProjectQuery, con)
                'Executing Dynamic Query
                cmd.ExecuteNonQuery()
                ReDim a_Opp(i)
                'Code in order to update the account
                Dim oppor As New Opportunity
                oppor.Id = oppQR.records(i).Id
                oppor.TransferProject2GP__c = "Sucess"
                a_Opp(i) = oppor
            Next
            login()
            binding.update(a_Opp)
            con.Close()
        Catch ex As Exception
            MsgBox("Project do not meet criteria or System is already Synced..." & ex.Message & "Querying Records")
        Finally
            con.Close()
        End Try

    End Sub

 

HI,

 

Here is the code :

<script>
jQuery(document).ready(function(j$){
//Slider
j$('.benefits').hide();
j$('.benefit-link').click(function() {
j$('.greybox').removeClass('on');
j$('.benefits').slideUp('normal');
if(j$(this).next().is(':hidden') == true) {
j$(this).parent().addClass('on');
j$(this).next().slideDown('normal');
}
});
//Set Payment Ammount
$("input:radio[name=member_level],").change(function(){
$("#member_val").val($(this).val());
$("#amount").val((Number($("#member_val").val()))+(Number($("#additional_val").val())));
$("#payment_total .total").html($("#amount").val()/100);
})
//Add Additional Value
$("#additional_donation").change(function(){
$("#additional_val").val($(this).val());
$("#amount").val((Number($("#member_val").val()))+(Number($("#additional_val").val())));
$("#payment_total .total").html($("#amount").val()/100);
});
});

</script>

 

 

 

Hi I found this class and I made some adjustments in order to use it.

 

Here is my class:

 

Public Class SlideShow
{

    public String notiDescription { get; set; }
    public String notiID { get; set; }

        //1st Product Photo
    public List<Product__c> Prodphoto {get; set;}
    public String P_imageTag {get; set;}
    public Integer P_strt=0,P_ed=1,P_len=0,P_i=0,P_indx=0;
    public String photo_tmp {get; set;}
    
    //2nd Product Photo
    public List<Product__c> Prodphoto_two {get; set;}
    public String P_imageTag_two {get; set;}
    public Integer P_strt_two=0,P_ed_two=1,P_len_two=0,P_i_two=0,P_indx_two=0;
    public String photo_tmp_two {get; set;}
    
    //3rd Product Photo
    public List<Product__c> Prodphoto_tree {get; set;}
    public String P_imageTag_tree {get; set;}
    public Integer P_strt_tree=0,P_ed_tree=1,P_len_tree=0,P_i_tree=0,P_indx_tree=0;
    public String photo_tmp_tree {get; set;}

    //slideShow Photos
    public List<Noticia__c> photo {get; set;}
    public String imageTag {get; set;}
    public String photoUrl {get; set;}
    public Integer strt=0,ed=1,len=0,i=0,indx=0;
    public String tmp {get; set;}
    
        //slideShow Photos
    public List<Metrica__c> metrica_photo {get; set;}
    public String metrica_imageTag {get; set;}
    public String metrica_photoUrl {get; set;}
    public Integer metrica_strt=0,metrica_ed=1,metrica_len=0,metrica_i=0,metrica_indx=0;
    public String metrica_photo_tmp {get; set;}
    

   public void SlideShow()
   {
      strt=0;
      ed=1;
      len=0;
      i=0;
      indx=0;
      Integer count_foto = [SELECT COUNT() FROM Noticia__c];
      Integer rand_foto = Math.floor(Math.random() * count_foto).intValue();  
      // Retrieve first noticia Image          
      String sql = 'SELECT image__c,Descripcion__c, Id FROM Noticia__c A LIMIT 1 OFFSET ';
      sql = sql+rand_foto;
      photo = Database.query(sql);
      imageTag = photo.get(indx).image__c;
      notiDescription = photo.get(indx).Descripcion__c;
      notiID = photo.get(indx).Id;
      strt = imageTag.indexOf('src=',0) + 5;
      ed = imageTag.lastIndexOf('alt=') - 2;
      tmp = imageTag.substring(strt,ed);
   }
      public void SlideShowDesc()
   {
      notiDescription = photo.get(indx).Descripcion__c;
      notiID = photo.get(indx).Id;
   }
    public  SlideShow()
    {
    
      Integer count_foto = [SELECT COUNT() FROM Noticia__c];
      Integer rand_foto = Math.floor(Math.random() * count_foto).intValue();  
      // Retrieve first noticia Image          
      String sql = 'SELECT image__c,Descripcion__c, Id FROM Noticia__c A LIMIT 1 OFFSET ';
      sql = sql+rand_foto;
      photo = Database.query(sql);
      imageTag = photo.get(indx).image__c;
      notiDescription = photo.get(indx).Descripcion__c;
      notiID = photo.get(indx).Id;
      strt = imageTag.indexOf('src=',0) + 5;
      ed = imageTag.lastIndexOf('alt=') - 2;
      tmp = imageTag.substring(strt,ed);
      
      // Retrieve active Metrica          
      String metrica_sql = 'SELECT graphic__c FROM Metrica__c A WHERE A.Active__c =' + 'true';
      metrica_photo = Database.query(metrica_sql);
      metrica_imageTag = metrica_photo.get(metrica_indx).graphic__c;
     
      metrica_strt = metrica_imageTag.indexOf('src=',0) + 5;
      metrica_ed = metrica_imageTag.lastIndexOf('alt=') - 2;
      metrica_photo_tmp = metrica_imageTag.substring(metrica_strt,metrica_ed);
     
      // Retrieve 1st Random Product
      Integer count = [SELECT COUNT() FROM Product__c];
      Integer rand = Math.floor(Math.random() * count).intValue();      
      String foto_sql = 'SELECT Product_Logo__c FROM Product__c LIMIT 1 OFFSET '; 
      foto_sql = foto_sql + rand;
      Prodphoto = Database.query(foto_sql);
      P_imageTag = Prodphoto.get(P_indx).Product_Logo__c;
     
      P_strt = P_imageTag.indexOf('src=',0) + 5;
      P_ed = P_imageTag.lastIndexOf('alt=') - 2;
      photo_tmp = P_imageTag.substring(P_strt,P_ed);
      
      // Retrieve 2nd Random Product
      Integer count_two = [SELECT COUNT() FROM Product__c];
      Integer rand_two = Math.floor(Math.random() * count_two).intValue();      
      String foto_sql_two = 'SELECT Product_Logo__c FROM Product__c LIMIT 1 OFFSET '; 
      foto_sql_two = foto_sql_two + rand_two;
      Prodphoto_two = Database.query(foto_sql_two);
      P_imageTag_two = Prodphoto_two.get(P_indx_two).Product_Logo__c;
     
      P_strt_two = P_imageTag_two.indexOf('src=',0) + 5;
      P_ed_two = P_imageTag_two.lastIndexOf('alt=') - 2;
      photo_tmp_two = P_imageTag_two.substring(P_strt_two,P_ed_two);
      
      // Retrieve 3rd Random Product
      Integer count_tree = [SELECT COUNT() FROM Product__c];
      Integer rand_tree = Math.floor(Math.random() * count_tree).intValue();      
      String foto_sql_tree = 'SELECT Product_Logo__c FROM Product__c LIMIT 1 OFFSET '; 
      foto_sql_tree = foto_sql_tree + rand_tree;
      Prodphoto_tree = Database.query(foto_sql_tree);
      P_imageTag_tree = Prodphoto_tree.get(P_indx_tree).Product_Logo__c;
     
      P_strt_tree = P_imageTag_tree.indexOf('src=',0) + 5;
      P_ed_tree = P_imageTag_tree.lastIndexOf('alt=') - 2;
      photo_tmp_tree = P_imageTag_tree.substring(P_strt_tree,P_ed_tree);
    }          
   
    public void prev()
    {
      if(indx != 0)
      {
        indx = indx - 1;
        String sql =  'SELECT image__c,Descripcion__c, Id FROM Noticia__c A';
        photo = Database.query(sql);
        imageTag = photo.get(indx).image__c;
        notiDescription = photo.get(indx).Descripcion__c;
        notiID = photo.get(indx).Id;
     
        strt = imageTag.indexOf('src=',0) + 5;
        ed = imageTag.lastIndexOf('alt=') - 2;
        tmp = imageTag.substring(strt,ed);
      }
    }   

    public void nxt()
    {  
      len = [SELECT COUNT() FROM Noticia__c];
      if(indx < (len-1))
      {
        indx = indx + 1;
        String sql =  'SELECT image__c,Descripcion__c, Id FROM Noticia__c A';
        photo = Database.query(sql);
        imageTag = photo.get(indx).image__c;
        notiDescription = photo.get(indx).Descripcion__c;
        notiID = photo.get(indx).Id;
     
        len =imageTag.length();
        strt = imageTag.indexOf('src=',0) + 5;
        ed = imageTag.lastIndexOf('alt=') - 2;
        tmp = imageTag.substring(strt,ed);
      } 
    }       
}

 

Here is my test class that for some reason only covers 27% of the class:

 

@isTest
private class SlideShow_TestMethod // Name of the test class, Can be any name
{         
    static testmethod void SlideShow_TestMethod()   // Name of the test method. Must be the same as the class name 
    {
        SlideShow ss = new SlideShow();   // Initialize variable for original class 
        ss.SlideShowDesc();
        ss.prev();
        ss.nxt();
        ss.SlideShow();
    }   
     
}

 

Thanks for all the help in advance.

Im currently working on my testclass but when I do the calls its not covering the for loop inside my method. How do you test the code lines inside the for loop.

 

Code to be tested:

 

   public List<String> getLst() 
        {
            for(Product__c prod: [SELECT Product_Logo__c FROM Product__c ORDER BY Name])
            {
              imageTag = prod.Product_Logo__c;
              strt = imageTag.indexOf('src=',0) + 5;
              ed = imageTag.lastIndexOf('alt=') - 2;
              tmp = imageTag.substring(strt,ed);
              img_Lst.add(tmp);
            }
         
            return img_Lst;
        }

 

Is it possible to have a page break inside a quote template. What I want is to be able to insert a page break into the layout in order to present other sections in new pages.

 

Thanks for all the help in advance.

Hi!

 

Im currently tring to update a field from VB.NET to Salesforce but for some reason the code executes without problems but I do not see any changes on my salesforce instance: Heres my code :

 

Private Sub queryOpplnItem()

        Dim a_opplnitem(0) As netxarEE.sObject
        'Sql(Connection & Statements)
        Try
            con.ConnectionString = constr
            con.Open()
        Catch ex As Exception
            MsgBox("Error while establishing connection..." & ex.Message, "Insert Records")
        Finally
        End Try

        'get a list of oppLineItems
        Dim qr As QueryResult = Nothing
        qr = binding.query("Select Id,ITEMNMBR__c, Product_Description__c, ITEMCLASSCODE__c, CreatedDate From OpportunityLineItem WHERE oppcurrStage__c = " & "'Closed Won'")
        MsgBox(qr.records.Length)

        login()
        For i As Integer = 0 To qr.records.Length - 1
            Dim oppLnItm As OpportunityLineItem = qr.records(i)
            Dim itemQuery As String
            itemQuery = "INSERT INTO ITEMQTBL VALUES ('"
            itemQuery = itemQuery & oppLnItm.Id & "'" & ","
            itemQuery = itemQuery & "'" & oppLnItm.ITEMNMBR__c & "'" & ","
            itemQuery = itemQuery & "'" & oppLnItm.ITEMCLASSCODE__c & "'" & ","
            itemQuery = itemQuery & "'" & oppLnItm.CreatedDate & "'" & ","
            itemQuery = itemQuery & "'" & "0" & "'" & ")"
            cmd = New SqlCommand(itemQuery, con)
            cmd.ExecuteNonQuery()
            MsgBox(oppLnItm.Product_Description__c & oppLnItm.CreatedDate)
            ReDim a_opplnitem(i)
            oppLnItm.Id = qr.records(i).Id
            oppLnItm.Transfer2GP__c = True
            a_opplnitem(i) = oppLnItm
        Next
        binding.update(a_opplnitem)
        con.Close()
    End Sub

 

Is it possible to refresh master page from a visual force page that is embeded on the opportunity layout ??

 

Thanks for all the help.

 

I already tried calling JS functions like window. and doing the following in the controller:

 

 PageReference curPage = new ApexPages.StandardController(opp).view();
       curPage.setRedirect(true);
       return curPage ;

 

Hi,

 

Im having problems applying CSS styles to <apex:outputfield> . I am displaying an image from a rich field. when I try to apply the float:right; css propertie it does not work.

 

Someone knows how to fix this?

 

Thanks in advance!

 

REG

Hi im currently developing an apex class that calls an external webservice that I programmed in .net.

 

My question:

 

My web service recieves 2 parameters getDeuda(string ssn, string zipCode) but the response is of type datatable. Which data type I have in Apex that i can put the response of the data table. Do I have to change the webservice so its response is of a custom type class??????

 

 

Thanks for all the help in advance!

 

REG

Hi,

 

I have this line of code: For some reason when I load the page the enhanced list is not displaying with the height and with stablished. Any one knows why ?

 

<apex:enhancedList type="Noticia__c" rowsPerPage="25" customizable="true" height="300" width="950"  rendered="false" reRender="true"

 

Hi!

 

Im trying to apply some css for a toolbar but its not working properly.

 

CSS: File name : Styles

 

@charset "utf-8";
/* CSS Document */

navbar{background-color: #ff6600;background-image: url(images/pattern_03.png);}

 

Visual Force:

 

<!-- A simple example of a toolbar -->
    <apex:toolbar width="950" height="30" styleClass="navbar">
    </apex:toolbar>

 

Static Resource Name : myStyles

 

In terms of the zip im uploading : I have a directory called images ( all my images are here) and outside in the root directory I have my css.

 

Hi im having problems displaying a RTF Field. For some reason it displays all the HTML tags and i want the field to be displayed exactly as a i saved it when i created the record.

 

VF Code

<apex:page standardController="Noticia__c">
<apex:outputText escape="false">{!Noticia__c.Contenido__c}</apex:outputText>
</apex:page>

 

Thanks for all the help!

Hi,

 

Thanks for the help in advance!

 

Im currently working on a trigger that is supposed to insert ids of the quotes into a detail custom object named CSV_UPLOAD_HISTORY on the field (Quote__c Lookup(Quote)). Im getting an error that says im attempting to dereference a null object do not understand why (System.NullPointerException: Attempt to de-reference a null object: Trigger.assignQuoteIds: line 27, column 1).

 

Here is my code:

 

trigger assignQuoteIds on Quote (before insert) {
    
// Create the list that will contain all quote ID's
    List<Id> l_quote = new List<Id>();
    for(Quote qt: Trigger.new)
    {
        //Collect all Quote ID's
       l_quote.add(qt.OpportunityID);
    }
    
    // Map in order to match Quotes with their respectives CUH's
    Map<ID, CSV_UPLOAD_HISTORY__c> qtMap = new Map<Id, CSV_UPLOAD_HISTORY__c>();
    
    // Loop that creates the correct map between OppIDS and CUH's
    for(CSV_UPLOAD_HISTORY__c cuh : [SELECT OpportunityID__c
    FROM CSV_UPLOAD_HISTORY__c WHERE OpportunityID__c IN :l_quote])
    {
        qtMap.put(cuh.OpportunityID__c, cuh);  // Creating a map with the CUH's
    }
    
    // List in order to update the records with
    List<CSV_UPLOAD_HISTORY__c> l_cuh = new List<CSV_UPLOAD_HISTORY__c>();
    for(Quote qt: Trigger.new)
    {
        CSV_UPLOAD_HISTORY__c cuh = new CSV_UPLOAD_HISTORY__c ();
        cuh = qtMap.get(qt.OpportunityID);
        cuh.Quote__c = qt.Id; // line 27 !!!
        l_cuh.add(cuh);
    }
    
    //update l_cuh;
}

 

 

 

Hi,

 

Is there any possible way to restrict the creation of new records. For example I should not be able to create a new Quote unless a checkbox field is marked in the opportunity object.

 

Thansk in advance!

 

REG

Hi,

 

Im trying to find a way "if possible" to limit the values of a picklist on the Opportunity Object depending on the assigned user role.

 

Example:

 

     User---------Role

John Doe - Account Manager

 

Picklist Value:

Value1

 

     User---------Role

John Doe - Territory Manager

 

Picklist Value:

Value2

 

Thanks for any ideas or help about this matter.

 

Hi,

 

Im trying to sort opportunity products in the opportunity realated list. I know there is a button to do this manually. But i want to be able to sort the items with apex code. I know there is a field named: SortOrder for the object opportunity Line item, sadly it is a read only field.

 

Is there any work around for this????

 

Thanks for any help,

 

REG

I need a way to override or turn off the auto sort from opportunity line items. The OLI object has a field named SortOrder but it is read only so i cant update the field or anything. Someone knows any workaround to this situation.

 

Thanks,

 

REG

 

I was able to upload records into objects with a custom code in apex. My only problem is that the split function does not care about text delimiters. Is there any possible way to be able to split without afecting fields with commas inside a text delimiter.

 

Example : "DOG HAS , A HOUSE"

 

Example Code:

 

          String FileData = FileRecords.toString();
           FileData = FileData.replace('"', '');
     
           if(FileData <> NULL)
           {
              LineNo = FileData.split('\n');

 

Hi!

 

Im currently tring to update a field from VB.NET to Salesforce but for some reason the code executes without problems but I do not see any changes on my salesforce instance: Heres my code :

 

Private Sub queryOpplnItem()

        Dim a_opplnitem(0) As netxarEE.sObject
        'Sql(Connection & Statements)
        Try
            con.ConnectionString = constr
            con.Open()
        Catch ex As Exception
            MsgBox("Error while establishing connection..." & ex.Message, "Insert Records")
        Finally
        End Try

        'get a list of oppLineItems
        Dim qr As QueryResult = Nothing
        qr = binding.query("Select Id,ITEMNMBR__c, Product_Description__c, ITEMCLASSCODE__c, CreatedDate From OpportunityLineItem WHERE oppcurrStage__c = " & "'Closed Won'")
        MsgBox(qr.records.Length)

        login()
        For i As Integer = 0 To qr.records.Length - 1
            Dim oppLnItm As OpportunityLineItem = qr.records(i)
            Dim itemQuery As String
            itemQuery = "INSERT INTO ITEMQTBL VALUES ('"
            itemQuery = itemQuery & oppLnItm.Id & "'" & ","
            itemQuery = itemQuery & "'" & oppLnItm.ITEMNMBR__c & "'" & ","
            itemQuery = itemQuery & "'" & oppLnItm.ITEMCLASSCODE__c & "'" & ","
            itemQuery = itemQuery & "'" & oppLnItm.CreatedDate & "'" & ","
            itemQuery = itemQuery & "'" & "0" & "'" & ")"
            cmd = New SqlCommand(itemQuery, con)
            cmd.ExecuteNonQuery()
            MsgBox(oppLnItm.Product_Description__c & oppLnItm.CreatedDate)
            ReDim a_opplnitem(i)
            oppLnItm.Id = qr.records(i).Id
            oppLnItm.Transfer2GP__c = True
            a_opplnitem(i) = oppLnItm
        Next
        binding.update(a_opplnitem)
        con.Close()
    End Sub

 

Is it possible to refresh master page from a visual force page that is embeded on the opportunity layout ??

 

Thanks for all the help.

 

I already tried calling JS functions like window. and doing the following in the controller:

 

 PageReference curPage = new ApexPages.StandardController(opp).view();
       curPage.setRedirect(true);
       return curPage ;

 

Hi,

 

Im having problems applying CSS styles to <apex:outputfield> . I am displaying an image from a rich field. when I try to apply the float:right; css propertie it does not work.

 

Someone knows how to fix this?

 

Thanks in advance!

 

REG

Hi,

 

Thanks for the help in advance!

 

Im currently working on a trigger that is supposed to insert ids of the quotes into a detail custom object named CSV_UPLOAD_HISTORY on the field (Quote__c Lookup(Quote)). Im getting an error that says im attempting to dereference a null object do not understand why (System.NullPointerException: Attempt to de-reference a null object: Trigger.assignQuoteIds: line 27, column 1).

 

Here is my code:

 

trigger assignQuoteIds on Quote (before insert) {
    
// Create the list that will contain all quote ID's
    List<Id> l_quote = new List<Id>();
    for(Quote qt: Trigger.new)
    {
        //Collect all Quote ID's
       l_quote.add(qt.OpportunityID);
    }
    
    // Map in order to match Quotes with their respectives CUH's
    Map<ID, CSV_UPLOAD_HISTORY__c> qtMap = new Map<Id, CSV_UPLOAD_HISTORY__c>();
    
    // Loop that creates the correct map between OppIDS and CUH's
    for(CSV_UPLOAD_HISTORY__c cuh : [SELECT OpportunityID__c
    FROM CSV_UPLOAD_HISTORY__c WHERE OpportunityID__c IN :l_quote])
    {
        qtMap.put(cuh.OpportunityID__c, cuh);  // Creating a map with the CUH's
    }
    
    // List in order to update the records with
    List<CSV_UPLOAD_HISTORY__c> l_cuh = new List<CSV_UPLOAD_HISTORY__c>();
    for(Quote qt: Trigger.new)
    {
        CSV_UPLOAD_HISTORY__c cuh = new CSV_UPLOAD_HISTORY__c ();
        cuh = qtMap.get(qt.OpportunityID);
        cuh.Quote__c = qt.Id; // line 27 !!!
        l_cuh.add(cuh);
    }
    
    //update l_cuh;
}

 

 

 

Hi,

 

Is there any possible way to restrict the creation of new records. For example I should not be able to create a new Quote unless a checkbox field is marked in the opportunity object.

 

Thansk in advance!

 

REG

Hi All!

 

How do I present a link in my visualforce page that when the users click it it pops out a static resource I uploaded into my org. The file is a .csv file.

 

Thanks in advance.

 

REG

Hi ! Thank You in Advance!

 

I have a custom development and it works fine for windows users. I would like to be able to process csv files from a mac enviroment. Im using BLOB in order to to process Windows csv files. Any help would be greatly appriciated!

 

Here is my code :

 

public with sharing class UploadRecordUsingCSV {

    public UploadRecordUsingCSV(ApexPages.StandardController controller) {

    }

    // I wish to parse a file from MAC here
    public Blob FileRecords{get;set;}
    
    public String[] LineNo= new String[]{};
    public List<CSV_UPLOAD_HISTORY__c> AllUnit;
    
    Public Pagereference UploadFile()
     {
       integer FileRow = 1;
       String oppID = System.currentPageReference().getParameters().get('id');
       String oppName = [SELECT A.NAME FROM OPPORTUNITY A WHERE A.ID =:oppID].Name;
       Opportunity opp = [SELECT A.NAME FROM OPPORTUNITY A WHERE A.ID =:oppID];
       OPPDULHISTORY__c btchHist = new OPPDULHISTORY__c ();
       btchHist.Name = oppName + '-' + String.valueOf(Date.Today());
       insert btchHist;
       system.debug('Enter');
     try{  
       String FileData = FileRecords.toString();
       LineNo = FileData.split('\n');
       AllUnit = new List<CSV_UPLOAD_HISTORY__c>();
       system.debug('Entered****'+ AllUnit);
       
       
       for(Integer i=1;i<LineNo.size();i++)
        {
          
          
          CSV_UPLOAD_HISTORY__c cuh= new CSV_UPLOAD_HISTORY__c();
          String[] ActualData=new String[]{};
          ActualData=LineNo[i].split(',');
          
          // Parsin BLOB and STRINGS
          cuh.Name = oppID + ActualData[0] ;
          cuh.Batch_History__c = btchHist.Id;
          cuh.OpportunityID__c = oppID;
          cuh.Part_Number__c = ActualData[0];
          cuh.Qty__c = double.valueOf(ActualData[1]);
          cuh.VUC__c = double.valueOf(ActualData[2]);
          cuh.Discount__c = double.valueof(ActualData[3]);
          cuh.Gross_Margin__c = double.valueof(ActualData[4]);
          cuh.ImportTax__c = double.valueof(ActualData[5]);
          cuh.Tax__c = ActualData[6];
          cuh.Vendor__c = ActualData[7];
          
          
          cuh.Status__c = 'Succes!'; 
          cuh.File_Row__c = FileRow++;          
          AllUnit.add(cuh);
          }
        }catch(Exception e){system.debug('Please select a file!');}
        
       insert AllUnit;
       
      // PageReference curPage = new ApexPages.StandardController(opp).view();
      // curPage.setRedirect(true);
      // return curPage;
       return Null;
     }
}

 

Hi! Im currently working on a trigger in order to find the xtra information of the Opportunity Owner. If Someone can help me with the part im missing from my code it would great!

 

Thanks in advance!

 

REG

 

Heres my code :

 

trigger accountManager on Opportunity (before insert) {
    
    // Create a set of userids
    set<ID> L_am = new set<ID> ();
    for(Opportunity opp: Trigger.new)
    {
       L_am.add(opp.OwnerId);
    }
    
    // Query the user table to grab the information needed
    if(!L_am.isEmpty())
    {
       User[] L_user = [SELECT Name, Email, Phone FROM USER WHERE Id IN:L_am]; 
    }
       
}

 

Hi

 

I'm really lost on this one.

I have an After Update trigger on Product, when I hit the activate/deactivate action link on a product in the Products search result list the checkbox is updated correctly BUT the trigger is not fired.

For testing purposes I implemented a button to do the same and when I use it to  activate/deactivate it works fine.

 

Any suggestion why this happens and how to solve it and get the triggered fired when I use the action link?

 

Much appreciated

 

 

  • June 06, 2012
  • Like
  • 0

Hi,

 

I wanna be able to pass the CSV file to another class in order to process more records from the file since i have a governor for insert statements.

 

CODE:

 

public with sharing class UploadRecordUsingCSV {

    public UploadRecordUsingCSV(ApexPages.StandardController controller) {

    }

    
    public Blob FileRecords{get;set;}
    
    String[] LineNo= new String[]{};
    List<product_opportunity__c> AllUnit;
    
    Public Pagereference UploadFile()
     {
       system.debug('Enter');
       String FileData=FileRecords.toString();
       LineNo=FileData.split('\n');
       AllUnit = new List<product_opportunity__c>();
                system.debug('Entered****'+ AllUnit);
       for(Integer i=1;i<LineNo.size();i++)
        {
          product_opportunity__c pto = new product_opportunity__c();
          String[] ActualData=new String[]{};
          ActualData=LineNo[i].split(',');
          pto.Name = 'TEST';
          
          pto.OpportunityID__c = ActualData[0];
          pto.Part_Number__c = ActualData[1];
          pto.Vendor_Unit_Cost__c = double.valueOf(ActualData[2]);
          
          //AllUnit.add(pto);
          insert pto;
        }
       //insert AllUnit;
       return Null;
     }
}

 

 

Hi,

 

I just finished the code below. It works fine as my expect but I have a hard time writing the test code. Can anyone please have a look at it and help me write the test code? Thanks in advance.

 

trigger UpdateUpcoming on Task (after insert, after update)
{
    Set<id> AccountIDs = new set<id>();
    list<Account> AcctList = new list<Account>();
    for(task c : Trigger.new)
    {
        for(Account at:[Select id,upcoming_due__c From Account where id =: c.accountid])
        {
            if (date.valueof(c.ActivityDate) == null)
                at.upcoming_due__c = null;
            else
            if (at.upcoming_due__c == null)
                at.upcoming_due__c = date.valueof(c.ActivityDate);
            if (date.valueof(c.ActivityDate) < at.upcoming_due__c)
                at.upcoming_due__c = date.valueof(c.ActivityDate);
            else
                at.upcoming_due__c = at.upcoming_due__c;
            AcctList.add(at);
        }
    }
    update AcctList;
}

Hi,

 

When I insert a list of a custom object in apex it only fires my before insert for the first object on the list.

 

Anyone knows why ??

 

Thanks