• rscott
  • NEWBIE
  • 340 Points
  • Member since 2009

  • Chatter
    Feed
  • 11
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 43
    Replies

 

//this will fail reporting a size of 0
string s = 'first.second';
string[] part;
part = s.split('.');
System.DEBUG(part.size());

//this will work reporting a size of 2
string s = 'first_second';
string[] part;
part = s.split('_');
System.DEBUG(part.size());

 

I'm usign API version 20. Paste this into the Execute Anonymous window of the IDE. Anyone have any ideas?

 

I have the need to pre-populate certain data fields on a standard custom object page. The data will come from a Visualforce page. I have seen several posts detailing how to do this using the field Id. However, I need to package this code and install in various other orgs which will all have different field Ids. Some of these posts claim that the packaging mechanism will modify the field Ids to fit the target org, but I can't seem to get that to work. 

 

 

<apex:commandButton action="{!URLFOR($Action.Test_Line__c.New, null)}&CF00NA0000004cg8S={!Test__c.Name}" value="New Test Line" />

This is trying to add a new Test Line object that references an existing Test object. The field Id for Test__c.name is 00NA0000004cg8S. The "CF" gets prepended to make the control Id on the page.

 

There doesn't seem to be a programmatic way to get field Ids. And I don't see how the packaging system can recognize that "CF00NA0000004cg8S" is a field Id in order to replace it. Is there another way to do this that will result in a successful field Id replacement?

 

 

 

 

We have a managed package with many custom objects. Now, we are creating a package extension. This extension has some new custom fields added to several custom objects in the managed package. They package up just fine, the issue is getting an updated .object file so we can add it to our source control database (subversion). 

 

I am able to get updated standard objects we've added fields to (Eclipse > Force.com Project Contents, add objects - standard), but not custom objects. How can I get these updated files?

I am writing a test class and am running into this error:

Error: Compile Error: Illegal assignment from SOBJECT:Customer_Product__c to Id at line 11 column 9

 Here is my test class:

@isTest
private class BulkDensityTest{
    testmethod private static void TestTrigger() {
        Customer_Product__c cp = new Customer_Product__c
            (name = 'apple');
        insert cp;
        
        Customer_Bulk_Density__c  c = new Customer_Bulk_Density__c ();
        c.Name = '4';
        c.Metric_Label__c = 'kg/m3';
        c.Customer_Product__c = cp;
        insert c;
        
        System.debug('c:' + c);
        c = [SELECT ID, Name FROM Customer_Bulk_Density__c  WHERE id = :c.id];
        System.debug('c:' + c);
        System.assertEquals(c.Customer_Product__c, c.Name);
        Profile p = [select id from profile where name='Standard User'];

    User u = new User(alias = 'standt', email='standarduser@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');
System.runAs(u) {
// The following code runs as user 'u'
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId()); }
}
     

}

 

Here is the trigger:

 

trigger BulkDensityConversion on Customer_Bulk_Density__c (before insert) {
    Set<Id> bIds = new Set<Id>();

list<Customer_Bulk_Density__c> customerBulkDensityList = new List<Customer_Bulk_Density__c>();

if(StaticClass.doNotExecute ==true)
{
system.debug('Inserting'+StaticClass.doNotExecute);
    for(Customer_Bulk_Density__c c:trigger.new)
    {
     bIds.add(c.id);
     
     if(c.Metric_Label__c =='Lbs./ft3')
     {
     Double conversion = Double.valueof(c.Name) * 16.018;
         Long L1 = conversion.round();
        
      Customer_Bulk_Density__c s = new Customer_Bulk_Density__c(
        Metric_Label__c = 'Kg/m3',
        Name = String.Valueof(L1) + String.ValueOf(' ') + String.Valueof('Kg/m3'),
        Customer_Product__c=c.Customer_Product__c,
        Customer_Product_2__c=c.Customer_Product_2__c,
        Customer_Product_3__c=c.Customer_Product_3__c
        );
        customerBulkDensityList.add(s);   
        }
         else
        {
         Double conversion1 = Double.valueof(c.Name) * 1 / 16.018;
              Long L2 = conversion1.round();        
              
         Customer_Bulk_Density__c s = new Customer_Bulk_Density__c(
         
        Metric_Label__c = 'Lbs/ft3',
        Name = String.Valueof(L2) + String.ValueOf(' ') + String.Valueof('Lbs./ft3'),
        Customer_Product__c=c.Customer_Product__c,
        Customer_Product_2__c=c.Customer_Product_2__c,
        Customer_Product_3__c=c.Customer_Product_3__c
        
        );
        customerBulkDensityList.add(s);   
        } 
    }
    StaticClass.doNotExecute =false;
    if(!customerBulkDensityList.isEmpty())
    {
        insert customerBulkDensityList;
    }
    
    System.debug('****1 : B Id size '+ bIds.size());
 
  }
  else
  {
  StaticClass.doNotExecute =true;
  }

  }

 

How to I solve the error?

 

Thank you again

I just downloaded the new Force.com Explorer (beta). I can log in and see my schema. The problem is that when I expand an object, I don't see any child relationships or fields. I can run a query if I manually enter it, but the database schema section is not working properly. I've tried connecting to multiple clouds with the same issue. Anyone else having the same problem?

Hello everyone,

                             In the following piece of code I am unable to fetch the rows if the groupName consists of left open paranthesis '('  and right open paranthesis ')'.

 

for Eg: if groupName = Assisted Health program (AHP) Japan

 If i remove (AHP) then it is working fine. like if i have my groupname as 'Assisted Health Program'. I am able to fetch the rows.

 

So, how to fetch the rows even if it consists of paranthesis in the groupName?

 

 

 

this.groupName = ApexPages.currentPage().getParameters().get('group');
if (groupName != null) {
evs = [Select Time_Zone_Offset__c, Start_Time__c, Start_Date__c, Name, Id, End_Time__c From Offmax_cal__c where Business__c like :(groupName + '%')];

I'm trying to query something in a custom button JavaScript.  The query uses a reference field on the custom object record.  However the {!} returns with referenced object's name instead of id, so I can't use it in a SOQL statement.  For instance,with SFDC_Projects__c defined as a lookup/reference on SFL5_Time__c object,

soql=soql + "'{!SFL5_Time__c.SFDC_Projects__c}'";

gets 'steves project" instead of the id for the project.  Since I'm trying to find out another object that's related to the same project, I really need the id instead of the name.

 

The same way works just fine in APEX trigger.  What did I miss in the JavaScript/AJAX Toolkit environment?

I have a List Button placed on a related list which redirects to a VF page. The controller behind the VF page retrieves the list of selected options and the user then performs some operation on those options.

I would like to prevent the redirect to the VF page if the user has not selected any records. I've tried changing the button to a Onclick Javascript and I can detect whether or not there are any options selected, but I'm unable to then Submit their selection and redirect to the VF page. More precisely, I can submit and redirect to the VF page, but the selected options aren't recieved by the controller.

 

Is there a way to do this?

 

Here is the javascript on my List button

 

records = {!GETRECORDIDS($ObjectType.Job_Applicant__c)};

if (records.length < 1) {
  alert('Please select one or more options first.');
} else {
  this.form.action = '/apex/MyVFPage';
  this.form.submit();
}

 Appreciate any suggestions. Cheers.

 

Hello all,

I have created a visualforce page with a custom controller calls "Xcontroller". 

on my controller I have defined a member of my class "Y" like this:

 

"private static Y y = new Y(a,b);"

 

This line is executed on page load.

 

When I click on my page button "finish" I invoke the function I created in my controller called "finish".

 

In this function I call functions from my class y, for example:

 

public class y {

 

private static string z;

private static string A;

private static string B;

 

public y(string a, string b)

{

     A=a;

     B=b;

}

 

public string getZ()

{

return z;

}

 

public static void setZ(string zz)

{

    z=zz;

}

 

}

 

 

on my controller :

public with sharing class Xcontroller{

 

private static Y y = new Y(a,b);

 

public Xcontroller()

{

}

 

public pagereference finish()

{

string w= y.getZ();

}

 

 

the problem is that when I click on "finish" the value in 'w' is null although on the page load before it got a value!

 

Can anyone help me understand what I did wrong?

Thanks a lot,

Inbal

 

 

can anybody help me how to pass the javascript values to a  controller in a visualforce page

Here's the situation...

 

We have an external application that collects various data.  We like to have clients install an app in their Org that allows us to import data into their org without us having to collect a user/pass from them.

 

It seems like the partner API should be able to do this, but can't find it documented anywhere.

 

Thanks for any help.

Brian

visual force page:


<apex:page standardController="Quotation__c" extensions="sendEmail1" sidebar="false">
<apex:sectionHeader title="Quotation Information Form" printUrl="https://cs5.salesforce.com/apex/QuotePdf?id={!$CurrentPage.parameters.id}&sfdc.override=1"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Quotation Details" columns="1">  
                                     
                 <apex:outputField value="{!Quotation__c.Name}"/>
                <apex:outputField value="{!Quotation__c.To__c}"/>
               
               <apex:outputField value="{!Quotation__c.Address__c}"/>
               <apex:OutputField value="{!Quotation__c.Kind_Attn__c}"/>
               <apex:OutputField value="{!Quotation__c.Dear_Sir__c}"/>
               <apex:OutputField value="{!Quotation__c.Notes__c}"/>
               <apex:OutputField value="{!Quotation__c.Terms_and_Conditions__c}"/>
               <apex:OutputField value="{!Quotation__c.Items_Selected__c}"/>
                
                
            
            
               <!-- <apex:outputField value="{!Quotation__c.Items_Selected__r.Name}"/>
                <apex:outputField value="{!Quotation__c.}"/> -->
                
            </apex:pageBlockSection>
        </apex:pageBlock>

       
<apex:dataTable value="{!itemSelected}" var="fcst" width="100%" >
<apex:column width="8%" ><apex:facet name="header">Product</apex:facet><apex:outputLabel value="{!fcst.Product__r.name}" /></apex:column>
<apex:column width="8%"><apex:facet name="header">Item Description</apex:facet><apex:outputLabel value="{!fcst.Item_Description__c}" /></apex:column>
<apex:column width="8%"><apex:facet name="header">Unit Price</apex:facet><apex:outputLabel value="{!fcst.Unit_Price__c}" /></apex:column>
<apex:column width="8%"><apex:facet name="header">Quantity</apex:facet><apex:outputLabel value="{!fcst.Quantity__c}" /></apex:column>
<apex:column width="8%"><apex:facet name="header">Total Price</apex:facet><apex:outputLabel value="{!fcst.Total_Price__c}" /></apex:column>


</apex:dataTable>
<apex:commandButton value="send" action="{!send}"/>
       
    </apex:form>        
</apex:page>



Apex Controller:

 

public class sendEmail1
{
public Quotation__c quot;
public sendEmail1(ApexPages.StandardController controller)
 {
 }
 public sendEmail1()
 {
 quot=[select Id,To__r.Email from Quotation__c where id=:ApexPages.currentPage().getParameters().get('id')];
 }

public List<Items_Selected__c> getitemSelected ()
{
List<Items_Selected__c> ISRL =[select Product__r.name,Quantity__c,Item_Description__c,Unit_Price__c,Total_Price__c from Items_Selected__c where Quotation__c =: ApexPages.currentPage().getParameters().get('id')];
return ISRL;
}

public PageReference send()
{
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        PageReference pdf = Page.QuotePdf;
        pdf.getParameters().put('id',(String)quot.Id);
        pdf.setRedirect(true);
        Blob b = pdf.getContent();
        Messaging.EmailFileAttachment efa=new Messaging.EmailFileAttachment();
        efa.setFileName('attachment.pdf');
        efa.setBody(b);
        String address=quot.To__r.Email;
        email.setToAddresses(new String[]{address});
        email.setFileAttachments(new Messaging.EmailFileAttachment[]{efa});
        Messaging.sendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
        return null;
        
        }
        }

 


When the save Button is clicked,it is producing a Error as :ATTEMPT TO DEREFERENCE A NULL OBJECT.

 

Can i know where the problem had occured..

Hi,

 

Using the Database DML property SaveResult along with the for loop to retrieve list of the error messages pertaining to the records that did not get updated does not do me a whole lot of good without knowing the record ID!!!


I have found others having the difficulty of accepting that this is the nature of the DML property SaveResult.  If it is used to Insert I can understand you would not have an ID on a record that did not get inserted but this about existing records with an ID.

 

Does anyone know a work around still using the code:

 

Database.SaveResult[] results = Database.Update(opps, false)

 

that would allow me to include the ID in my email.  I need to be able to research the record in order to troubleshoot the "Why didn't the record update?" question.

 

Thanks in advanced.  Troubles and work arounds exist in all languages but Apex needs to catch up to the big league languages like C# and java.  That is just a want-a-be programmer's perspective.  In the mean time I am having a blast learning SFDC as a whole.

 

You guess make it that much more desirable to learn.

 

 

Hi,

I m trying to get all the values of a picklist (custom field) using apex, but still i couldn't.

Is there any way to do it ?

If you have, pls reply......

 

 

Thanks.

 

     List<Task> histories = [Select id,Ownerid,whatid,whoid,activitydate,subject,website__c From Task where (whatid=:relatedLink.id and Ownerid=:currentUser and Status='Not Started') limit 1]; 

 

 

 

I'm getting an exception when deploying that is telling me  "Too many query rows: 501".

 

Doesn't the "Limit 1" take care of this??

 

Thanks!

Hey,

 

I was looking to enhance user experience by providing some better error messages. The one I am trying to overload now, is where it does not have an ID it needs in the URL, so rather than saying 'List out of bounds', I would like to explain to users that they need to go back and select a new ID to continue. I tried the following:

LIST<Model_Definition__c> temp = [SELECT Name FROM Model_Definition__c WHERE Id = :ModelDefId LIMIT 1];
    try {
        return temp[0].Name;
    }
    catch(Exception e){
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error: No objects could be found. Most likely, you no longer have a model selected. Please return to the model selection screen'));
    }
    return null;

 

 

but I still get a blank page displaying just the list out of bounds error. Does anyone know the proper way to override those error pages/messages?

 

Thanks!

Hi All,

 

I work with an ISV Partner who has a developer org where a managed package is updated / upgraded / tested and then uploaded "privately' to the exchange for a set of clients to install.

 

The orgs that install my package have the standard EE limits applied to them.

 

Herein lies the issue I have come across, whilst doing some development a new TAB was inadvertently added to the managed package and subsequently uploaded as a 'managed - released' package. It took the custom TABS within the managed package to 26.

 

This as you can see has caused HUGE implications across the current install base and for new clients. The package is constantly being updated / customised to suit clients needs and updates are continously being pushed however now that it has 26 TABS it will not install on any of the orgs as it reaches the 25 custom tab limit.

 

I REALLY NEED HELP BRAINSTORMING SOME POSSIBLE SOLUTIONS!!!

 

As I see it there are a range of possibilities and I look to any sf reps / partner ops / product managers subject matter experts out there to let me know what is feasible.

 

IDEAL SOLUTION - Since the tab that has been added is not installed on any clients org (it physically cannot be because of the limit on the install orgs, developer org doesn't have a tab limit) - I'm looking for an overall package admin or someone that can reference or edit the package I have created and manually remove the tab from it altogether. It can be deleted from the salesforce developer instance altogether I don't care it's not needed at all! Support tells me it cannot be deleted but someone out there must have access to it!!

Is there a way to 'rollback' to a previous package version that only had 25tabs in it's managed set>? And then be able to delete the 25th tab somehow completely from the developer org?

 

Other options include:

 

Going through the LMA process and getting the application security checked so that it's contents do not affect sf org limits. This is obviously primary concern right now however the whole process could take up to 2-3 weeks which is time we don't have! This problem needed to be sorted out YESTERDAY!

 

Upgrading provisions on future clients and current installbase so that orgs can install apps with more than 25 tabs. (i.e. increase tab limit)

 

I really need to know if the ideal solution is feasible here as that would be well... Ideal. But I'm interested to see if anyone has any other suggestions.

TIME IS A FACTOR. There are new clients coming on board this week and next not to mention the current install base that is catered for in package updates so this really needs to get sorted out.

 

As always any help is much appreciated. Thanks in advance for any reads of this post.

 

Patrick