• MattL
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 26
    Replies
I have a VisualForce page that contains an attachment upload (basically, overriding the attachments related list). However, upon upload, the page refreshes entirely. This normally wouldn't be a problem, except that it doesn't re-render the detail, and that section is rather important to the overall flow of the page. I was under the impression that rerender would rebuild the list with a partial page refresh... however, I attempted to use this functionality when adding documents from Salesforce, and while the document is added, you don't see it in the list until you do a manual refresh. What am I doing wrong?

VisualForce Page
Code:
<apex:page standardController="Agreement__c" extensions="documentExt,ec_mod_cntrl" >
    <apex:detail relatedList="false" />
    <apex:pageBlock >
        <apex:pageBlockSection title="Attachments">
            <apex:pageBlockTable border="0" cellpadding="6" value="{!attachments}" var="a" id="rows">
                <apex:column headerValue="Title"><apex:outputField value="{!a.Name}" /></apex:column>
                <apex:column headerValue="Last Modified"><apex:outputField value="{!a.LastModifiedDate}" /></apex:column>
                <apex:column headerValue="Created By"><apex:outputField value="{!a.LastModifiedById}" /></apex:column>
            </apex:pageBlockTable>
            <br />
            <apex:tabPanel switchType="client" selectedTab="File">
                <apex:tab label="From File" name="File" id="file">
                    <apex:form id="newfile">
                        <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" />
                        <apex:commandButton value="submit" action="{!save}" />
                    </apex:form>
                </apex:tab>
                <apex:tab label="From Salesforce" name="SFDC" id="sfdc">
                    <apex:form id="newsf">
                        <apex:selectList size="1" value="{!selectedProd}">
                            <apex:selectoptions value="{!items}" />
                        </apex:selectList>
                        <apex:commandButton value="Find Documents" rerender="doc" />
                        <br />
                        <apex:outputPanel id="doc">
                            <apex:actionStatus startText="Polling Folder {!selectedProd}">
                                <apex:facet name="stop">
                                    <apex:selectList size="1" value="{!selectedDoc}">
                                        <apex:selectoptions value="{!items2}" />
                                    </apex:selectList>
                                </apex:facet>
                            </apex:actionStatus>
                        </apex:outputPanel>
                        <apex:commandButton value="Add Document" action="{!svdoc}" rerender="rows" />
                    </apex:form>
                </apex:tab>
                <apex:tab label="From External Respository" name="ECRepo" id="ecrepo">
                    <apex:pageMessage detail="A link to the external Repository goes here." severity="warning" />
                </apex:tab>
            </apex:tabPanel>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 Controller Extension documentExt
Code:
public class documentExt {
 private final String ecagree;
 public Attachment attachment {get;set;}
 
 public PageReference save() {
  attachment.parentid = ecagree;
  insert attachment;
  return null;
 }
 
 public documentExt(ApexPages.StandardController controller) {
  attachment = new Attachment();
  this.ecagree = ApexPages.currentPage().getParameters().get('id');
  this.stdController = stdController;
 }
 
 ApexPages.StandardController stdController;
}

Controller Extension ec_mod_cntrl
Code:
public class ec_mod_cntrl {
 public String selectedProd {get;set;}
 public String selectedDoc {get;set;}
 public List<Attachment> attachList;
 public List<SelectOption> docs = new List<SelectOption>();
 public PageReference reset() {
     attachList = [select id, Name, LastModifiedDate, LastModifiedById from Attachment where ParentId = :ApexPages.currentPage().getParameters().get('id')];
        return null;
    }
 public List<Attachment> getAttachments() {
     if(attachList == null) reset(); 
        return attachList;
    }
    public void setAttachments(List<Attachment> Attach) {
        attachList = Attach;
    }
 public ec_mod_cntrl(ApexPages.StandardController controller) {
  
 }
 public List<SelectOption> getItems() {
     List<SelectOption> dfolder = new List<SelectOption>();
        for(Folder fd : [Select Id, Name from Folder where Type='Document']) dfolder.add(new SelectOption(fd.Id, fd.Name));
        return dfolder;
    }
    public List<SelectOption> getItems2() {
     queryDocs();
     return docs;
    }
    public PageReference queryDocs() {
     docs.clear();
     for(Document d : [Select Id, Name from Document where FolderId=:selectedProd]) docs.add(new SelectOption(d.Id, d.Name));
     return null;
    }
    public void svdoc() {
     Document d1 = [Select Id, Body, Description, Name, Type from Document where Id=:selectedDoc];
     if(d1!=null)
     {
      Attachment a1 = new Attachment();
      a1.Body=d1.Body;
      a1.ContentType=d1.Type;
      a1.Name=d1.Name;
      a1.ParentId=ApexPages.currentPage().getParameters().get('id');
      insert a1;
     }
    }
}

 

 


I've run into a bit of a problem with the governor limits on the SOQL query rows returned. Here's my situation.

The code needs to query the organization for all accounts whose type is "Customer". Then, it needs to find the largest existing Account Number, and increment it by 1, storing that new value into an account that's type is updated to Customer, or a new Customer account.

Trigger:
Code:
trigger Account_Number_Inc on Account (after insert, after update) {
 if(Trigger.new[0].Account_Number__c == null && Trigger.new[0].Type == 'Customer')
 {
  list<Account> AcctNums = [SELECT Account_Number__c From Account where Account_Number__c != null and Type = 'Customer' ORDER BY Account_Number__c DESC NULLS LAST];
  System.assert(AcctNums != null);
  Long curhigh = long.valueOf(AcctNums[0].Account_Number__c);
  curhigh++;
  Account acc = new Account(Id=Trigger.new[0].Id);
  acc.Account_Number__c=String.valueOf(curhigh);
  update(acc);
 }
}

 
Test Code:

Code:
public class AccountNumberTriggerTest {
 static testMethod void testAccountTrigger() { 
    Integer highestnum = integer.valueOf([Select Account_Number__c from Account where Account_Number__c != null and Type = 'Customer' ORDER BY Account_Number__c DESC NULLS LAST][0].Account_Number__c);
    Account b = new Account(name='blah2', type='Customer');
    insert b;
    Integer acctnum = integer.valueOf([Select Account_Number__c from Account where id =:b.id][0].Account_Number__c);
    System.assertEquals(highestnum+1, acctnum);
    }
}

 Now, my problem is that when I attempt to deploy it from the Sandbox, I get an error "Too many query rows". Upon trying to LIMIT my query, I've discovered that the LIMIT occurs before the ORDER BY, so if I limit the query, I don't get all the records and may not actually get the highest account number (depending on how Salesforce returns the records). But if I don't limit the query, I get errors of Too many query rows.

Any advice?

I'm trying to pull in the ID of a row... unfortunately, despite setting an <apex:param> for it, when I query the variable I assigned it to I always get "null" back.

Visualforce:
Code:
<apex:page controller="cntrl_ext_save" sidebar="false" >
<apex:sectionHeader title="Professional Development Products" />

 <apex:form >
 <apex:selectList size="1" required="true" value="{!selectedProd}">
<apex:selectoptions value="{!items}"/>
</apex:selectList>
<apex:commandButton action="{!add}" value="New Dev. Product" />
 <apex:pageBlock title="Items">
   <apex:pageBlockButtons >
     <apex:commandButton value="Save"  action="{!save}"  rerender="rows" status="outStatus"/>
     <apex:commandButton value="Reset" action="{!reset}" rerender="rows" status="outStatus" 
      immediate="true" />
     <apex:actionStatus startText="(.................Processing.................)" stopText="" id="outStatus" onstop="Reset"/>
   </apex:pageBlockButtons>
   <apex:pageBlockTable border="1" cellpadding="6" value="{!components}" var="a" id="rows" >
      <apex:column headerValue="Delete"><apex:commandButton value='Del' action='{!remove}' onclick="return confirm('Are you sure—');"><apex:param value="{a.Id}" assignTo="{!dParam}" /></apex:commandButton></apex:column>
      <apex:column headerValue="Product">"{!a.PricebookEntry.Name}"</apex:column>
      <apex:column headerValue="Quantity"><apex:inputField value="{!a.Quantity}" /></apex:column>     
      <apex:column headerValue="Sales Price"><apex:inputField value="{!a.UnitPrice}" /></apex:column>
      <apex:column headerValue="List Price">"{!a.ListPrice}"</apex:column>
      <apex:column headerValue="Total Price">"{!a.TotalPrice}"</apex:column>
   </apex:pageBlockTable>
  </apex:pageblock>
 </apex:form>
</apex:page>

 Controller:
Code:
public class cntrl_ext_save {
        public String selectedProd {get;set;}
        public String dParam;
        public String getdParam() {
            return dParam;
        }
        public void setdParam(String s) {
            dParam = s;
        }
        public List<OpportunityLineItem> componentList;  // list of components to appear in the multi-line.
        public PageReference reset() {
            componentList = [select id, quantity, totalprice, unitprice, listprice, PricebookEntry.name, pricebookentry.product2.Family from OpportunityLineItem where OpportunityId = :ApexPages.currentPage().getParameters().get('id') and pricebookentry.product2.Family = '03 Professional Services'];
            return null;
        }  
        public List<OpportunityLineItem> getComponents() {
            if(componentList == null) reset(); 
            return componentList;
        }
        public void setComponents(List<OpportunityLineItem> Components) {
            componentList = Components;
        }
        public PageReference save() {
            upsert componentList;
            return null;    
        }
        public PageReference add() {
            Opportunity pb = [select Pricebook2Id from Opportunity where Id = :ApexPages.currentPage().getParameters().get('id')];
            PricebookEntry prod = [select UnitPrice, Name, Id from PricebookEntry where Product2Id = :selectedProd and Pricebook2Id = :pb.Pricebook2Id];
            componentList.add(New OpportunityLineItem(OpportunityId = ApexPages.currentPage().getParameters().get('id'), UnitPrice=prod.UnitPrice, PricebookEntryId=prod.Id, Quantity=1));
            save();
            reset();
            return null;                
        }
        public PageReference remove() {
            system.debug('test '+dParam);
            OpportunityLineItem oli = Database.query('select Id from OpportunityLineItem where id='+dParam);
            delete oli;
            reset();
            return null;
        }
        public List<SelectOption> getItems() {
            List<SelectOption> op = new List<SelectOption>();
            for(Product2 prod : [select id, name from Product2 where family='03 Professional Services']) op.add(new SelectOption(prod.Id, prod.Name));
            return op;
        }
}

 


Hello,
I have created a custom button to display in new window where the content source is a custom s-control (HTML).  All works well but I would like to be able to control the properties of the window before it opens (size, scroolbars, statusbar, toolbar).  Where can I find those properties?
Thanks!!!
I am trying to apply style to field label and field data in a s-control. Its getting applied but i am not getting exactly same look and feel as salesforce. I have included sfdc style sheets and i have applied the right class also but it looks like i am missing some thing. here is the small snippet.

It would be grt if someone can guide me if i am missing anything else. Thx. Deepak.
Hi,
 
I am trying to create the following formula field in a custom object named Product. I want the product name to be generated dynamically from the Brand Name and denomination field selected for the product. Brand is a lookup field in Product Obejct. When I save the following formula, it says "Error: Field Brand__r does not exist. Check spelling."
 
Formula:
 
Brand__r.Name & "-" &    TEXT(Denomination__c)
 
If I use Brand__c & "-" &    TEXT(Denomination__c) , the the 15-digit Brand ID is displayed instead of name.
 
Please let me know is there is any workaorund for this.
 
Thanks for your help.
 
Ambili
Hi,
 
I am starting to learn s-control on the job. 
 
I created a S-control ( as url, an external .Net application ).  I have two questions.
 
1. How to attatch it to a custom button ?  I am able to override a standard button. But I do not want that. I want to create new custome button and call the s-control on click of that button. Is this feature available now  in Enterprise edition?
 
2.  How to pass parameters from salesforce screen to this s-control when the user clicks on it ? I want to pass IDs of the case screen , when the user clicks on the custom button or link ? Can someone please help me with a sample code snippet,
 
 would really appreciate your answers to the questions above  !!
 
 
Thanks,
Meena
I'm looking for a way to update an Opportunity (calculate something and update some fields) whenever an Opportunity was modified.
Is there a way to implement an s-ontrol that does this and attach it to the opportunity? I heard something about inline s-controls but couldn't figure out if that's what I need.

I know that I can do that with triggers (appex code) but I would like to use an s-control.

Can someone helpe me?
I want to make the custom page in salesforce.I also want the look and feel of the custom page as any other  pages we have in salesforce(Eg Account ,Contact).

Please help me how to start with the first step in making the custom page by the help of S-controls.

Regards
Mohit


I need to update the owner on 242  cases.  We have a custom field in the cases object that contains an internal user's alias 'JSMITH' that would signify 'John Smith'.  The 242 cases need to update the owner field with the full name identified by the custom field alias name.  So, if the custom field contains 'JSMITH' then the case owner would need to be updated to 'John Smith'.
 
What would be the easiest and most efficient way to handle this batch update?
 
Thank you.
Code:
<—xml version="1.0" encoding="utf-8"–>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 xmlns:salesforce="com.salesforce.*"
 applicationComplete="login();">

<mx:DateFormatter id="dateform" formatString="MM"/>
<mx:NumberFormatter id="numform" precision="0"/>

<mx:Script>
 <![CDATA[
  import flash.external.ExternalInterface;
  import com.salesforce.results.QueryResult;
  import mx.collections.ArrayCollection;
  import com.salesforce.AsyncResponder;
  import com.salesforce.objects.LoginRequest;
  import mx.controls.dataGridClasses.DataGridColumn;
  private function login():void {
   apex.login( new LoginRequest({
    server_url : this.parameters.server_url,
    session_id : this.parameters.session_id,
    callback : new AsyncResponder(render)
    })
    );
  }
  private function render(result:Object):void {
   var currId:String = ExternalInterface.call("getID");
   apex.query("Select Amount, CloseDate, OwnerId from Opportunity where AccountId='{!Account.Id}' and Probability=100",
     new AsyncResponder(
     function (qr:QueryResult):void
     {
      var month:int = 0;
      var x:int = 0;
      var amt:Array = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0);
      var name:Array = new Array(" "," "," "," "," "," "," "," "," "," "," "," "," ");
      var months:Array = new Array("0","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
      var ar:ArrayCollection = new ArrayCollection();
      values.dataProvider = ar;
      for(var j:int=0;j<qr.records.length;j++) {
       month=numform.format(dateform.format(qr.records[j].CloseDate));
       amt[month]+=qr.records[j].Amount;
       apex.query("Select Name from User where Id='"+qr.records[j].OwnerId+"'",
       new AsyncResponder(
       function (qr2:QueryResult):void
       {
        name[x]=qr2.records[0].Name;
        x++;
       },
       function (fault:Object):void {}
       ));
      }
      ar=createArray(months, amt, name, ar);
     },
     function (fault:Object):void {}
  ));
 }
 private function createArray(months:Array, amt:Array, name:Array, ar:ArrayCollection):ArrayCollection {
  for(var i:int=1;i<13;i++)
  {
   ar.addItem( {Month:months[i], Amount:amt[i], Name:name[i]});
  }
  return(ar);
 }
 ]]>
</mx:Script>

<salesforce:Connection id="apex" />
 <mx:ColumnChart x="118" y="46" id="values">
  <mx:series>
   <mx:ColumnSeries displayName="Opp Amounts" yField="Amount"/>
   <mx:ColumnSeries displayName="Owner" yField="Owner"/>
  </mx:series>
 </mx:ColumnChart>
 <mx:Legend dataProvider="{values}"/>
 
</mx:Application>

I'm learning how to code simple Flex graphs, and I'm trying to push all my information into the ArrayCollection ar. The problem is that, regardless of what method I try, I'll put a breakpoint on the line return(ar) and a breakpoint on the line x++ under my second AsynchResponder. Inevitably, the return(ar) function will activate PRIOR to the breakpoint for x++, which means none of my names are initialized before the ArrayCollection is created. How does one 'wait' for all the data to be returned?
 


Message Edited by MattL on 01-28-2008 11:38 AM
XXX



Message Edited by muronghe on 07-16-2008 12:08 PM
Hi I have the following S-Control and then following the Iframe opening up at the Homepage as a component...
But it is slow to load the homepage when they sign in any one has any ideas how to make it fast...PLZZZ
Code:
<html> 
<head> 
<meta http-equiv=“refresh” content=“600″ /> 
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script> 
<script type="text/javascript"> 
window.onload=init_page; 
function init_page() 
{ 
var j= ""; 
var output=""; 
strSQL = "Select Id,AS400_Account_Number__c,Name,BillingCity,SF_DATE_ON_SERVICE__c from Account where OwnerId='{!$User.Id}' and SF_DATE_ON_SERVICE__c = LAST_N_DAYS:30 ORDER BY SF_DATE_ON_SERVICE__c DESC"; 
var result = sforce.connection.query(strSQL); 
var records = result.getArray("records"); 
for (var i=0; i<records.length; i++) 
{ 
j +='<a href="/' + records[i].Id + ' "target=_blank"">' + (i+1) +') ' + records[i].SF_DATE_ON_SERVICE__c + ' - ' + records[i].AS400_Account_Number__c + ' - ' + records[i].Name + ' - ' + records[i].BillingCity + '</a><br>&nbsp;' 
} 
document.getElementById('div_tag').innerHTML = j ; 
} 
</script> 
</head> 
<body bgcolor="#F3F3EC"> 
<font size="2" face="Verdana"> 
<div id="div_tag">No Accts</div></font> 
</body> 
</html>

 
Can salesforce report on how often a field changes or is it limited to only reporting the last modified date.  I'm trying to track how often users are editing their cases

I'm developing an S-control where one of the fields is a picklist value. Ideally, I wouldn't need to hard-code the values in. Going through the Sforce Explorer, I can navigate under the field name down to "type - picklist" and then "Picklist Values", but I can't figure out how to structure my SOQL query to gain access to this data. Can anyone advise if it's even possible, or will I need to resort to hard-coding it in?  
I am looking for a way to auto populate fileds so they are read only on a customer obkect. Esstentially a deal would have a vendor based on a relastionship look up. The vendors phone number and address are stored under their contact information. The phone number would be "shown or copied" onthe deal.

Any easy way of doing this?

Thanks

Steve
Hey,
 
There may be similar threads on this topic, but here goes anyway:
 
>>>>
YES:  SEE RECENT POST
WHICH IS THE EXACT SAME THING, OR NEARLY SO
<<<<
 
We have an org from which we're sourcing a managed package, and I'm trying to connect to it using the new Force.com Eclipse plug-in (v. 11.1.1).  The SOAP Endpoint is v. 11.1 as well.  What I get when connecting, and also when trying to 'refresh from server', or 'synchronize with server', is a msg box with the following error:
 
Unable to perform synchronization.
 
Reason:
TeamException: null: Duplicate retrieve names specified for package '<pkg name>'
 
I see a stack trace in my workspace log; if anybody wants to see it, I'd be happy to add it to this thread.
 
Does anybody have some insight into this, and what I can do about it, or how I can work around it?  Let's say for the sake of discussion that I do NOT want to re-create my org from scratch.  :^}
 
Thanks!
 
-phil m.


Message Edited by philbo on 01-14-2008 10:19 AM