• JFraile
  • NEWBIE
  • 105 Points
  • Member since 2011

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

I have a field called Bid_Specification__c which I need to be required on the object only for new records so I was thinking I could use if the created date is null. 

 

However, this is a custom object and I just noticed there is no created date field.  I don't know why but I would have thought this would be part of the initial field creattion when I created this object such as created by, record owner, etc.

 

Do I need to create a custom field called Created Date and does the validation rule run prior to saving it so it will recognize that the created date is null?

 

Not sure of the syntax for this formula either.  Any help is much appreciated.  thanks. :-)

Hello,

 

I have a (before insert, before update) trigger on a custom object called Assignment that reassigns the record ownerID to a user ID based on a custom field in the Assignment object that looks up to another custom object called Requested Employee that looks up to a user record.

 

In addition I have a workflow rule that populates the users email in a custom field on the Assignment object.

 

The trigger works, I am able to reassign the owner, but only when the workflow rule is active. When I deactivate the workflow rule, the record owner will not reassign when I insert a new record, it will only update after I have edited a record TWICE.

 

My question is...why does this occur. I'm relatively new to SF and Apex, and trying to learn what is going on behind the scenes in this situation.

I'm assuming the workflow rule has some effect on the records contained in the Trigger.NEW list but I am having trouble wrapping my head around what is going on.

 

Any help or advice would be greatly appreciated.

 

Thanks!

  • January 23, 2013
  • Like
  • 0

Hey folks,

 

As I forward my opportunity from org A, it is not accetped automatically by org B, even if Auto-Accept is enabled. What's the problem?

 

Thanks!

Josh

Hi.

 

How can I change my domain name prefix (xxxxxx.force.com) to another (yyyyyyy.force.com)?

 

Regards.

Hi.
I have a button wich invokes a VF page wich invokes an apex method that creates a new record and then invokes another method wich creates a PDF (using a VF renderas PDF and its controller) for this new record.

When I push the button the new record is created and a PDF is attached to it. (The record is an invoice, and the PDF is this invoice PDF.) The problem is that the PDF has no content at all, cannot even open it, and just has 9 bytes. But, once I've created the new record, if I run just the method that creates de PDF, a new PDF is attached to the invoice, this time with content in it.

debugging my code I've found where the error seems to be. The VF controller throws an exception when it tries to retrive data using the newly created record id, passed by page parameter, here is the code:

public with sharing class ControllerTestGetContent {      
        public List<OpportunityLineItem> productos;                
        public ControllerTestGetContent (ApexPages.Standardcontroller stdController){        	
        	}
public List<OpportunityLineItem> getProductos(){
        	string ide = ApexPages.currentPage().getParameters().get('Id');
        	system.debug('The invoice Id is: '+ide);// THIS DEBUG RETURNS THE RIGHT INVOICE ID
         try{        	
                Factura__c a=[select Oportunidad__c from Factura__c where
                Id=:Ide]; // BUT THIS OTHER THROWS A EXCEPTION System.VisualforceException: List has no rows for assignment to SObject

 

I've tried different ways to perform this query, with the same result.

The code that invokes the VF is this:

public class CrearFacturaPDF{
	public CrearFacturaPDF() {}
	public CrearFacturaPDF (ApexPages.StandardController controller){}
    public static boolean CrearPDF2(string ID_Fac){  
	[...]
	    PageReference ElPDF = Page.TestgetContent;    	
    	ElPDF.getParameters().put('id',ID_Fac);     
    	// create the new attachment
    	Attachment attach = new Attachment(); 
    	// the contents of the attachment from the pdf
    	Blob body; 
    	try { 
    	    // returns the output of the page as a PDF
    		body = ElPDF.getContent();    		    		
   		 } catch (VisualforceException e) {
    		body = Blob.valueOf('Some Text');    		
   		 }
The code that creates the new record and invokes the CrearPDF2 method is:
public with sharing class CrearFacturaProforma {
	public CrearFacturaProforma(ApexPages.StandardController controller) { }	
	public PageReference CrearProforma() {
		[...]
		insert FacturaProforma;               
        boolean done = CrearFacturaPDF.CrearPDF2(FacturaProforma.Id);                
        PageReference Volver_A_Detalle = new PageReference('/' + FacturaProforma.Id);
        Volver_A_Detalle.setRedirect(true);
        return Volver_A_Detalle;

It seems like it's not possible to create a new record and ,under the same running process, create a PDF for this new record. Is it that way? must it be done throght two separate execution processes?

Thanks.


 

 

 

    
                  
Thanks.

 

Hi, I'm trying to set two picklists dynamically in my VF page. The first picklist is 'Type' and the second is 'Subtype'. 'Subtype' depends on 'Type'. They both are implemented as custom settings (list) object 'CongifTerciarios__c' with the standard field 'Name', which represents the Type, and six custom fields 'Subtipo1', 'Subtipo2' , 'Subtipo3', 'Subtipo4', 'Subtipo5', 'Subtipo6'. So for each type I have one new register of the CongifTerciarios__c object.

 

My VF code is:

 <td><apex:selectList value="{!TipoActivo}" multiselect="false" size="1"  style="auto">
                    <apex:actionSupport event="onchange" reRender="subtipo" status="status"/>
                    Tipo:<br /> <apex:selectOptions value="{!TipoActivo1}"/>
                </apex:selectList></td>
    <td><apex:outputPanel id="subtipo"><apex:actionStatus id="status" startText="Cargando "/>
        <apex:selectList value="{!SubtipoActivo}" multiselect="false" size="1" rendered="true" style="auto">
                    Subtipo:<br />
 <apex:selectOptions value="{!SubtipoActivo1}"/>
                </apex:selectList>
</apex:outputPanel></td> 

 

And my controller code is:

public without sharing class terclassbusqueda2{
        
    public terclassbusqueda2(){
    }
    public list<GIAI_IP__Provincia__c> ListaProvincias = [select Name, IdProvinciaPortal__c from GIAI_IP__Provincia__c];
    public map<String, list<String>> MapaTipos = new map<String, list<String>>();
    public Decimal Nsubtipos = 0; 
    public list<CongifTerciarios__c> TiposTerciarios = [select Name, Subtipo1__c,   Subtipo2__c,Subtipo3__c,Subtipo4__c,Subtipo5__c,Subtipo6__c from CongifTerciarios__c];  
.
.
 public string getTipoActivo(){ return this.TipoActivo; }
    public void setTipoActivo(string s){ this.TipoActivo = s; }
.
.
 public List<SelectOption> getTipoActivo1() {
        List<SelectOption> Options = new List<SelectOption>();
        for (CongifTerciarios__c obj : TiposTerciarios){
            list<String> subtipos = new list<String>();
            subtipos.add(obj.Subtipo1__c);
            subtipos.add(obj.Subtipo2__c); 
            subtipos.add(obj.Subtipo3__c);
            subtipos.add(obj.Subtipo4__c);
            subtipos.add(obj.Subtipo5__c);
            subtipos.add(obj.Subtipo6__c);
            MapaTipos.put(obj.Name, subtipos);
            Options.add(new SelectOption(obj.Name,obj.Name));
        }
        return Options;
    }
    
    public List<SelectOption> getSubtipoActivo1() {
        List<SelectOption> SubOptions = new List<SelectOption>();
        string tipoterciario = string.valueof(this.TipoActivo);
        for(String nombre : MapaTipos.Keyset()){
            if(tipoterciario == nombre){
                   list<String> subtipostemp = new list<String>();
                   subtipostemp = MapaTipos.get(nombre);
                   for(String Sub : subtipostemp){
                       if(Sub != null)   
                           SubOptions.add(new SelectOption(Sub ,Sub));
                   }  
            }
        }
        return SubOptions;
    }  
   

 

     The problem comes when a new field is added (subtipo7__c, subtipo8__c,...) to the custom setting object 'CongifTerciarios__c' or deleted. Because the controller can not manage these situations dynamically:  adding this new field to 'subtipos' list in 'getTipoActivo1' Method, and in the 'TiposTerciarios' Select. Similar case if field deleted

 

(Adding new fields to the Select is posible using the 'getAll'  custom settings method, or the describe method and build a query, I already tried that and it worked. If a new 'CongifTerciarios__c' register is created, it means a new type is created, the code dynamically manage it properly. But if a new subtype is added, or an already existing one is deleted, the code doesn´t manage that. I need the code to be able to manage new fields or deleted ones dynamically.)

 

Thanks.

Hope my explanation is not to blurred ;)

Hi.

 

I get this error message when creating a new site. "duplicate value found: unknown duplicates value on record with id: 005Z0000000QYR4 " where the id:005Z0000000QYR4 belongs to a user. There are no user validation formulas.

 

 

I've been throught the forum but no solution found.

 

Thanks.

 

Hi,

 

I have a custom obj in which I have lookup relationships to both opportunities and account. 

My req is to filter the opps based on the account selected. That is after selecting an account when I click on the opp lookup button I only want the dialog box to show those opps that are related to the selected opp. 

 

I found that we can use lookup filters for implementing this. But however when I try to edit the particular relationship field in the custom object, it does not show a Lookup filter settings section. But this section does show up for lookup fields on account and user. Why is it not showing up here?

 

 

Below is the code which creates the related child object it works fine for sys admin but doesn't work for other profile

 

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}

{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")} var url = parent.location.href;

var prjid='{!Project__c.Id}';

var TaskId='{!Task__c.Id}';

result = sforce.connection.query("Select Status__c,Project__c from Task__c where Status__c not in ('Complete','Cancelled') and Project__c='"+prjid +"'");

 

var records = result.getArray("records");

var date = new Date('{!TODAY()}');

var i = records.length; if(i>0)  

  {     parent.location.href = url;  

   window.alert("All Tasks need to be completed before the project can be closed.");

}

else{

var createqod = new sforce.SObject("Quality_of_delivery__c");

createqod.Project__c = "{!Project__c.Id}";

createqod.Name = "{!Project__c.Name} ";

createqod.Approved_Status__c="Pending input from Dev Specialist";

createqod.Number_of_Change_Requests__c=0;

createqod.date__c=date; createqod.Final__c="True";

createqod.Dev_Lead__c="{!Project__c.Dev_Lead_UserId__c}"

sforce.connection.create([createqod]);

parent.location.href = url; window.alert("A final Quality of Delivery record has been created for the project. It needs to be updated and approved by Dev Lead - only then the project will be closed");

 

 

 

 

}

I am trying to adjust my search page so that when a user search returns no results a message is displayed stating such.  However, at the moment while the search results for records that do exist display correctly, the error message does not show up when no matching records are found.  I would appreciate any help anyone could offer getting it fixed and have included my code snippets below.

Controller:

public with sharing class searchTestController {
 
  private ApexPages.StandardController controller {get; set;}
  public List<MG_Contract_Holder__c> searchResults {get;set;}
  public string searchText {get;set;}
 
  // Standard controller
  public searchTestController(ApexPages.StandardController controller) { }
 
  // Search button clicked
  public PageReference search() {
    String qry = 'select Vin_Number__c, Name, First_Name__c, Vehicle_Make__c, Vehicle_Model__c, Vehicle_Year__c, Product_Group__c, Effective_Date__c, Expiration_Date__c, Contract_Status__c, Contract_Number__c From MG_Contract_Holder__c ' +
    'where Vin_Number__c =:searchText order by name';  
    searchResults = Database.query(qry);
    
    if(searchResults == null){
    ApexPages.Message errormessage = new ApexPages.Message(ApexPages.Severity.ERROR,'No Records found.');
    ApexPages.addMessage(errormessage);
    }
    return null;
  }
}

 VF Page Search Form:

 <apex:form >
    <apex:pageBlock mode="detail" id="block">
       
      <apex:pageBlockSection >
      <apex:outputLabel for="searchText">Find a Customer - Enter a Vin Number:</apex:outputLabel>
          <apex:panelGroup >
          <apex:inputText id="searchText" value="{!searchText}" maxlength="17"/>
          </apex:panelGroup>
        <apex:commandButton value="Search" action="{!search}" rerender="block" status="status"/>
        <apex:pageBlockSectionItem >
        <apex:messages />
        </apex:pageBlockSectionItem>
      </apex:pageBlockSection><br/>
 
      <apex:actionStatus id="status" startText="Searching... please wait..."/>
      <apex:pageBlockSection title="Search Results" id="resultsBlock" columns="1">
          <apex:pageBlockTable value="{!searchResults}" var="item" rendered="{!NOT(ISNULL(searchResults))}">
          <apex:column style="text-align:center;" value="{!item.Name}" headerValue="Last Name" width="85"/>
          <apex:column style="text-align:center;" value="{!item.First_Name__c}" headerValue="First Name" width="85"/>
          <apex:column style="text-align:center;" value="{!item.Contract_Number__c}" headerValue="Contract #" width="85"/>
          <apex:column style="text-align:center;" value="{!item.Vehicle_Make__c}" headerValue="Make" width="85"/>
          <apex:column style="text-align:center;" value="{!item.Vehicle_Model__c}" headerValue="Model" width="85"/>
          <apex:column style="text-align:center;" value="{!item.Vehicle_Year__c}" headerValue="Year" width="85"/>
          <apex:column style="text-align:center;" value="{!item.Product_Group__c}" headerValue="Product" width="85"/>         
          <apex:column style="text-align:center;" value="{!item.Effective_Date__c}" headerValue="Effective Date" width="85"/> 
          <apex:column style="text-align:center;" value="{!item.Expiration_Date__c}" headerValue="Expiration Date" width="85"/>
          <apex:column style="text-align:center;" value="{!item.Contract_Status__c}" headerValue="Status" width="85"/> 
        </apex:pageBlockTable>
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>

 

Hi! 

 

I want to create a workflow using the Products section (located in the object "Opportunities"). 

(This is the section "Products").

 

I need to create a rule that, everytime I add a new product, an email is sent to X person.

 

But the problem here is that the fields in the product section does not appear when I try to create the rule. I believe that they are not regular fields.

 

Can anybody help me with this?

 

Thanks in advance!

  • January 29, 2013
  • Like
  • 1

I have the requirement to set a custom CampaignMemberStatus ('Duplicate') for new added duplicate CampaignMembers (duplicate in my case means the underlying Contac/tLead have the same email address).

 

Because a CampaignMember trigger can contain CampaignMembes from different campaigns i'm not sure what will be the best/efficent way to query the already existing CampaignMembers without hitting governer limits.

 

My first thoughts are:

1. Collecting all email addresses that are existst in current the trigger bulk.

2. Collecting all campaign ids that are exist in the current trigger bulk.

3. Querying all CampaignMembers that uses an email address from the current bulk and are in a campaign from the current bulk.

 

Something like this:

SELECT Id, campaignId, email__c
FROM CampaignMember
WHERE CampaignId IN :campaignIds
AND email__c IN :emailAddresses
AND Status != 'DUPLICATE'
AND email__c != null

 

 

Notes about the query:

1. email_c is a formula field which contains the email address from the underlying object depending if the object is a Contact or Lead.

2. select all members that are IN the bulk campaign ids _AND_ are IN the bulk email addresses.

4. exclude already as duplicate marked members (only get the originals) to reduce the result even more (to know there exists at least one member with this email address is sufficient).

 

I'm aware of that the condition in 2. will also fetching members that are not interesting for me (example: member with email 'a' that is in campaign 'b', but the bulk contains the email 'a' only for campaign 'c'). So i must check the result against the current bulk in apex afterwards (check if member in same campaign with same email).

 

But i think this should be ok or at least should not break the govenor limits.

 

 

In a worst case scenario we can have a bulk with:

1. 200 members from different campaigns.

2. each member has a different email.

3. each of the 200 campaigns contain at least 200 members with this email addresses.

 

So this would mean that we can get a maximum query result of 40000 members (limit is 50000). Because we also must iterate over the result (to check against the current bulk) we must also keep the logic there very keen/compact to not hit the script lines limit. I think the heap limit can also be passed by using a soql loop.

 

For me this approach looks very complex for on the first sight very simple requirement. Because i'm new to apex development i'm also not so confident in my expectations about the limits. ;)

 

I would be happy to hear any thoughts on this approach and i'm also open to other solutions for the problem.

 

Thanks for taking the time to read this!

 

Greetings

Luca

 

P.S. The code should run in a managed package and therefore it should be robust and also pass the security review!

  • January 26, 2013
  • Like
  • 0

I have a field called Bid_Specification__c which I need to be required on the object only for new records so I was thinking I could use if the created date is null. 

 

However, this is a custom object and I just noticed there is no created date field.  I don't know why but I would have thought this would be part of the initial field creattion when I created this object such as created by, record owner, etc.

 

Do I need to create a custom field called Created Date and does the validation rule run prior to saving it so it will recognize that the created date is null?

 

Not sure of the syntax for this formula either.  Any help is much appreciated.  thanks. :-)

Is it possible to send an email when we share a record to an user. i want to notify the user with whom the record is shared.

Can we write trigger after we manually share a reaord.??

Hello,

 

I have a (before insert, before update) trigger on a custom object called Assignment that reassigns the record ownerID to a user ID based on a custom field in the Assignment object that looks up to another custom object called Requested Employee that looks up to a user record.

 

In addition I have a workflow rule that populates the users email in a custom field on the Assignment object.

 

The trigger works, I am able to reassign the owner, but only when the workflow rule is active. When I deactivate the workflow rule, the record owner will not reassign when I insert a new record, it will only update after I have edited a record TWICE.

 

My question is...why does this occur. I'm relatively new to SF and Apex, and trying to learn what is going on behind the scenes in this situation.

I'm assuming the workflow rule has some effect on the records contained in the Trigger.NEW list but I am having trouble wrapping my head around what is going on.

 

Any help or advice would be greatly appreciated.

 

Thanks!

  • January 23, 2013
  • Like
  • 0

I want to add functionality in a custom button to convert a pending agreement into an agreement.

Both Pending Agreement and Agreement objects are custom objects.

So when viewing a Pending Agreement and the convert to agreement button is clicked, then a check will be performed to see if an agreement already exists, if it does then edit the record otherwise create a new record.

How would I go about creating this functionality?

  • January 23, 2013
  • Like
  • 0

I have two users A and B with their own diferent role hierarchies( ie, user A comes under Org->CEO->hier-1 and user B comes under Org->CEO->hier-2). 

Now i have an account and some opportunities related to that acount. The OWD is private.

 

I have two sandbox instances. In one of the sandboxes, I can view all the user B owned opportunities related to the account while logged in as user A. Please note that I do not have any sharing rule in place for opportunities object that shares the records between these two users in this sandbox.

 

In the next sandbox, with the same situation(ie, OWD private and no sharing rules), I cannot see the user B owned opp records related to the same account while logged in as user A.I am confused here. How can user A view opportunity records owned by user B when there is no sharing rule in place? Can someone please explain. Is there anything more than the sharing settings that I should be looking for?

Hi,

 

Any one can help drag and drop in vf page. I want to display contact records in a box and also display  three empty boxes first box contacts  dragable and dropable in remaining boxes when droped a record an event will fire. Is it possible in visual force page? Any one knew this?

 

 

Thank you.

Hi 

 

we have a client org where Person Account is enabled. we want to know what are the fileds specific to "Person Account" record types and "Business Account" recordtypes using Apex.

 

please let me know if anyone has idea about this.

 

Thanks in advance

 

Regards

Rakesh

I am new to developer force.com ......I Had one problem while developing an Recrutingapplication in developer force.com

         

                                    Requirement is:-

             

                                                                 I need to have a Registration Form and Login page how can I develop those Forms ?

 

Hi All,

 

Please help me anyone aware of the issue.

 I have a requirement. I have a field like Opportunity currency(standard field) in Opportunity object. After created the opportunity nobody are able to edit the currency field. because that Opportunity have some products.  So we are try to add some code that does this for them - e.g. a visual force page where they choose the new currency, and the controller deletes the products, changes the currency and then adds the products back again. and based on the Opportunity currency many fields are caliculating internally,that is the issue what i am facing.

 

anybody please provide sample code to resolve the above issue. I am new to salesforce development . can you please provide the trigger logic if possible. Ex: trigger deleteandaddproducts on Opportunity (before update,after update) { // Need logic to delete the Opportunity products when before update // and add deleted opportunity records into opportunity after update } Anybody please help me out...... Thanks,

Hey folks,

 

As I forward my opportunity from org A, it is not accetped automatically by org B, even if Auto-Accept is enabled. What's the problem?

 

Thanks!

Josh

I'm trying to contact the salesforce api from my rails app. I use omniauth-salesforce gem for oauth.

As mentioned in the REST API documentation, I have setup a remote access provider in "Setup". This asks me for a static callback URL. But the issue with my system, each user of my app gets a different domain. So, I cannot set a constant callback url like "user1.demoapp.com". I will have basically 100 domains for 100 users. So, is it possible to override this callback URL from my rails app? Please let me know.