• arishi0
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 20
    Replies

Hello,

 

I have a visualforce page exposed in a force.com site. This site is open to the public and guests should be able to access this page through my clients website, a link there would take them to my site. What I need is to pass an IDcode through that link so that when the visualforce page is shown it will have the code in its controller.

 

The idea is that the page is access by many of my clients and each has their own code, this is important so that when creating the controller class I will be using this "Idcode"  to fetch some of the clients data such as rates and availability.

 

How can I do this???

Hello,

 

I am creating a VF page in my org BUT I want to be able to expose it (once completed) in any one of my custromers website (not under the Force.com Sites platform).  

 

The idea is that every customer of mine should be able to see this reservation visualforce page in one of their webpages for their sites. The visualforce page should be able to send information to SF and then retrieve reuslts to which the customer will be able to select one of those results and send it back to SF for creating the custom record.

 

Imagine a hotel with a reservations component calling to SF to get the available rooms based on user input. Then displaying it in the webpage and sending back the selection from the user for processing in SF. This would resoult in a reservation record created in SF and more workflow to fire off.

 

I am not sure how to approach this....Any ideas?

 

 

 

 

Hello,

 

Could anyone assist me with the following issue I have:

 

I have created an apex class that does some querying of accounts and custom objects in preparation to making a query for the related contact records. Basically I have a Product/services object that is referenced in a PArticipation Details object that is in turn referenced in an Account. Therefore the class would return ALL contacts at the accounts for a certain Product/Service.

Since some of those product/services are very famous, there are some that return over 10,000 contacts and for that reason, that part of the querying must be done in an apex batch job.

 

I have debugged the results and the contacts list is updated with the scope list in the execute method, BUt for some reason the visualforce page is not updated with the resulting list. Below is the code of the visualforce page and the controller:

 

 

global class contact_fromAcc_by_ProdServ implements Database.Batchable<sObject> {
   
    VRDbg.VRDebugLogger vrdl = new VRDbg.VRDebugLogger();
    public Id selectedProduct {get;set;}
    public List<Account> accs;
    private List<Contact> contacts= new List<Contact>();
    public List<Id> pdsAccIds = null;
    public Products_Services__c currentProduct;   
    public List<Participation_Detail__c> tempPDList;
    public List<Contact> ContactList {get{return contacts;}set;} 
    
    //constructors
    public contact_fromAcc_by_ProdServ(ApexPages.StandardController standard) {
    }
    public contact_fromAcc_by_ProdServ() {
    }         
    
    //Product Service List objects - PROPERTY
    public List<SelectOption> PS_Items {
        get {
            List<selectOption> options = new List<selectOption>();
            options.add(new SelectOption('','-- Choose a Product/Service --'));
            for(Products_Services__c p: [SELECT Id, Name,Type__c from Products_Services__c WHERE P_S_Status__c = 'Active' ORDER BY Name ASC]){
               // this.currentProduct = p;
                options.add(new SelectOption(p.Id,p.Name));
                selectedProduct = p.Id;}
                return options;
            }
        set;}
   
 

    //Method to calculate contact list
public void updateContactList() {        
        if (selectedProduct != NULL) {
            pdsAccIds = new List<Id>();
            tempPDList = [Select p.Account__c 
                          From Participation_Detail__c p 
                          WHERE p.Product_Service__c = :selectedProduct AND p.Status__c = 'Current'];
            //get Account Ids in temp PD list.
             for(Participation_Detail__c pd: tempPDList){
                if(pd.Account__c != null){
                   pdsAccIds.add(pd.Account__c); 
                }
            }
            //execute batch job to get contact data from Account listing.
            if(this.pdsAccIds != null){
                Database.executeBatch(this, 50000);
                ContactList = contacts;
            }
      }
    }//end method
    
      
      public void clearList (){
        this.contacts.clear();
        //this.contacts = null;
      }
      
      //////// Mandatory implementation of Batchable processes interface to retrieve contacts from SF
     global Database.queryLocator start (Database.BatchableContext ctx){
        return Database.getQueryLocator([SELECT
                                                c.Id, c.Full_Name__c, c.AccountId , 
                                                c.Account.Master_Account_Status__c , c.Account.Sub_Status_IMS__c, 
                                                c.Account.SubStatusSynXisCRS__c, c.Account.Sub_Status_Sabre_GDS__c, 
                                                c.Account.Sub_Status_Hotel_RFP__c, c.Account.Sub_Status_Internal__c , 
                                                c.Contact_Type__c, c.Email, c.HasOptedOutOfEmail, c.Subscriptions_SynXis_Selected__c, 
                                                c.Subscriptions_Customer_Selected__c 
                                        FROM Contact c 
                                        WHERE 
                                                c.No_Longer_with_this_Account__c !=True 
                                                AND c.EmailBouncedDate = null 
                                                AND Account.Id IN:pdsAccIds ]);
    }
    
    global void execute(Database.BatchableContext BC, list<Contact> scope){
        for(Contact con:scope){
            this.contacts.add(con);
        }
         vrdl.logIt('Contacts list size: ' + contacts.size() + ' || Scope list size: ' + scope.size() + 'ContactList method: ' + ContactList);
         vrdl.send();
    }
    
    global void finish(Database.BatchableContext BC){} 
      
    
}//end class

 and the visualforce page:

 

<!--Product/service name 
Account Owner (when AM is the Account Owner) 
Instead of Full Name make link to Contact record? 
Add Sub-Status fields 
Take out Fax field 
Email Opt Out? 
Maybe a link to the Participation Detail record?-->
 
<apex:page tabStyle="Products_Services__c"   controller="contact_fromAcc_by_ProdServ" pageStyle="Contact"  sidebar="false" standardStylesheets="true" showHeader="false" >  
<apex:pageBlock >
        <apex:sectionHeader /> 
        <font color="black" size="5" align="center">Contacts @ Accounts by Product Service</font><br/><br/>
         This page will let you select a Product/Service and it will list all the contacts that are related to accounts that contract that Product/Service via Participation Details. First select
         a Product/Service from the picklist below then wait for the contacts to be calculated and displayed onscreen. Once you can see the contacts, you can permorm regular view actions such as sort,
         export excel file, add/remove fields, etc.        
    </apex:pageBlock>
    <br/> 
<!-- Page block to list all ProductServices-->
<apex:pageBlock >
    <apex:form >
        <apex:pageBlockSection title="     Active Product Services" showHeader="true" collapsible="false" dir="" columns="2">
               <apex:selectList value="{!selectedProduct}" size="1" multiselect="False" id="products" >
                   <apex:selectOptions value="{!PS_Items}" id="psi"/>
               </apex:selectList>
               <apex:commandButton action="{!updateContactList}" rerender="contactlist" status="Constatus" title="Click to update Contact list" value="Update Contact List" /> 
        </apex:pageBlockSection>
        <apex:pageBlockSection title=" Contacts List" showHeader="true" collapsible="false">
                <apex:pageBlockSectionItem >
                    <apex:commandButton value="Export to Excel" action="/apex/contacts_romAcc_by_ProdServ_EXCELexport"/>   
                </apex:pageBlockSectionItem> 
                <apex:pageBlockSectionItem >
                    <apex:actionStatus id="Constatus">
                        <apex:facet name="start" >'Updating Contact List...'</apex:facet>
                    </apex:actionStatus>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
           <br/>
            <apex:pageBlockSection >
               <apex:outputPanel id="contactlist" >
                  <apex:pageBlockTable width="100" value="{!ContactList}" var="c" id="dt" >
                     <apex:column >
                         <apex:facet name="header">Full Name</apex:facet>
                         <apex:outputLink value="/{!c.Id}" target="_blank">{!c.Full_Name__c}</apex:outputLink>
                     </apex:column>

                     <apex:column value="{!c.AccountId}" width="250">
                         <apex:facet name="header">  Account Name  </apex:facet>
                     </apex:column>              

                     <apex:column value="{!c.Account.Master_Account_Status__c}">
                         <apex:facet name="header">Account Master Status</apex:facet>
                     </apex:column>                    

                    <apex:column value="{!c.Account.SubStatusSynXisCRS__c}">
                         <apex:facet name="header">Sub Status Synxis CRS</apex:facet>
                     </apex:column>                    

                    <apex:column value="{!c.Account.Sub_Status_Sabre_GDS__c }">
                         <apex:facet name="header">Sub Status Sabre GDS</apex:facet>
                     </apex:column>  
                      <apex:column value="{!c.Account.Sub_Status_Hotel_RFP__c}">
                         <apex:facet name="header">Sub Status Hotel RFP</apex:facet>
                     </apex:column>
                     <apex:column value="{!c.Account.Sub_Status_IMS__c}">
                         <apex:facet name="header">Subscriptions - Customer Selected</apex:facet>
                     </apex:column> 
                      <apex:column value="{!c.Subscriptions_SynXis_Selected__c}">
                         <apex:facet name="header">Subscriptions - Synxis Selected</apex:facet>
                     </apex:column>
                      <apex:column value="{!c.Subscriptions_Customer_Selected__c}">
                         <apex:facet name="header">Subscriptions - Customer Selected</apex:facet>
                     </apex:column>                                 
                      <apex:column value="{!c.HasOptedOutOfEmail}">
                         <apex:facet name="header">Email Opt Out</apex:facet>
                     </apex:column>     
             </apex:pageBlockTable>             
             </apex:outputPanel>
         </apex:pageBlockSection> 
           <br/> 
         <apex:pageBlockSection >
             <apex:panelGrid columns="3"> 
                 <apex:commandButton value="Export to Excel" action="/apex/contacts_romAcc_by_ProdServ_EXCELexport"/>
                 <apex:outputLabel style="color:#404040;"> ***IMPORTANT: Due to SF restrictions, the EXPORT TO EXCEL button only works with  the Google CHROME or Mozilla FIREFOX browsers. If it is run from IE6/7 it will NOT download the excel file.***
</apex:outputLabel>
             </apex:panelGrid> 
         </apex:pageBlockSection>
     </apex:form>
</apex:pageBlock>
</apex:page>

 

 

Thank you!!!

 

I have a trigger that works on a custom object called Sales Credit Detail and is supposed to add a sharing to theOpportunity owner (which is a related object via lookup).

 

Our org wide default for this Sales Credit object is Private and not using hierarchies to grant access. The idea is that ONLY the sales credit detail owner AND the opportunity owner can edit the sales credit detail (from now on SCD) record. An Opportunity can have many SCDs and for each the owner of that record gets default FULL access, BUT also for each of these I want to add the Opportunity owner to be able to have full access to it as well.

 

I decided to add a trigger that would add a share to the SCD for the Opp owner BUT when I edit the SCD record, the rule is not created for the Opportunity owner. BElow is the code, can someone see if I am failing somewhere? I cannot figure it out. I have tested the list sizes and the opp owner etc and they all give the correct value, so I dont know why it is not working

 

 

trigger Opportunity_Owner_share on Sales_Credit_Detail__c (after insert, after update) {
    //Create list of sharing records to create for SCDs in api call. 
    List<Sales_Credit_Detail__Share> SCD_Shares = new List<Sales_Credit_Detail__Share>();
    List<Sales_Credit_Detail__c> SCDS;
   
   //get all Opportunities for all SCD that will be inserted.
   List<Opportunity> opps = [SELECT Id, OwnerId, Name From Opportunity Where Id IN(SELECT ParentOpportunity__c From Sales_Credit_Detail__c Where Id IN :Trigger.newMap.keyset())];
   System.Debug(opps.size());
   
   //For each SCD record being inserted/edited, create a sharing record to the Opportunity owner of that SCD
    for(Sales_Credit_Detail__c scd: Trigger.new){
	   Sales_Credit_Detail__Share scd_share = new Sales_Credit_Detail__Share();
	   scd_share.ParentId = scd.Id;
	   scd_share.AccessLevel = 'All';
	   scd_share.RowCause = Schema.Sales_Credit_Detail__share.RowCause.Opportunity_Owner_Access__c;
	   System.Debug(scd_share.RowCause);
	  
	   for(Opportunity o:opps){
	   	//Add share record to list of shares to upload IF not for Opp Owner same as SCD owner
	       if(o.Id == scd.ParentOpportunity__c && o.OwnerId != scd.OwnerId){
	           scd_share.UserOrGroupId = o.OwnerId;
	           }       	
	       }
	    // Add the new Share record to the list of new Share records.
	    SCD_Shares.add(scd_share);
	    System.Debug(SCD_Shares);
        }
        //Insert all shares to the Database.
        Try{
         insert(SCD_Shares);
        }catch (Exception e){
        	System.Debug(e);
        }
}

 

 

 

I keep getting a System.QueryException: List has no rows for assignment to SObject  exception for a trigger I created. I am not sure how to solve the issue, can anyone help????

 

 

trigger CalculateTotalBonusPercentageNEW on Sales_Credit_Detail__c (before insert, before update) {

    //Declaring Global Variables
    map<Id, Commission__c> currentCommissionsMap = new map<Id, Commission__c>();
    Id oppOwnerId;
    Account OppAcc;
    Sales_Goal__c sg;
    Boolean test = true;
    String probando;
    
    // get all current commissions      
    for(Commission__c c : [Select Id, Accelerator__c, End_Date__c, Start_Date__c From Commission__c Where Start_Date__c <= :System.today() AND End_Date__c >= :System.today()])
      {	currentCommissionsMap.put(c.Id, c);}
    
    for (Sales_Credit_Detail__c scd : trigger.new){
    	Id scr = scd.Sales_Credit_Recipient__c;
    	
    	//if trigger is insert then change owner to SCR.
        if(Trigger.IsInsert){scd.OwnerId = scr ;}
        
        //Map the SCD's Opportunity to a variable
        Opportunity o = [SELECT Id, AccountId,CloseDate,Type,CommPerN__c,StageName,Name,New_Business_Type__c 
                                From Opportunity where ID = :scd.ParentOpportunity__c LIMIT 1];
                                System.Debug(o);
       try{ 
            // get sales goal for SCD Recipient. Check currentCommissionsMap is not null.
            if( currentCommissionsMap.isEmpty()){
            	test = false;
            }else{
                  sg = [select Met_Date__c, User__c, Commission__r.Accelerator__c 
                        From Sales_Goal__c 
                        Where User__c = :scr  AND Commission__c IN :currentCommissionsMap.keySet() LIMIT 1];
            }           
            if( sg == Null){test = false;}
            
            //validate if account region and Opp parameters are correct, if so write to total bonus Percentage with extra kicker, else write only Commission Percent New value
          if(test == true){
                if (sg.Met_Date__c != null &&  o.CloseDate >= sg.Met_Date__c &&
                 o.Type == 'New Business' && 
                 o.StageName == 'Closed Won' && 
                 (o.New_Business_Type__c.equalsIgnoreCase('New Account') || 
                 o.New_Business_Type__c.equalsIgnoreCase('Add Prop Existing Acct') || 
                 o.New_Business_Type__c.equalsIgnoreCase('Add Prod/Srvcs Existing Acct') || 
                 scd.ParentOpportunity__r.New_Business_Type__c.equalsIgnoreCase('Parent/Chain/Partner Switch')) 
                 ){
                    Decimal accelerator = (sg.Commission__r.Accelerator__c > 0) ? sg.Commission__r.Accelerator__c : 0;
                    scd.zCommAccel__c = accelerator;
                    scd.Total_Bonus_Percentage__c = o.CommPerN__c + accelerator;
                   }
           } else {
                    scd.zCommAccel__c = 0;
                    scd.Total_Bonus_Percentage__c = o.CommPerN__c;
            }
                 
       }catch (Exception e){
            scd.addError( e + ' Test:' +  test + '  /' + ' sg:'+  sg);
            // 'There was a problem when saving your Sales Credit Detail record. Please validate that the Opportunity values are correct or that the User has a sales Goal and that the Met Date is less than the Opportunity Close Date.'   
       }
    }
}

 

 

Hello,

 

I have a home page component that displays text from a field in a custom object called FrontPageNews. The idea is to load into the component the latest news we have in our org.

 

What I did was to create a VF page that uses a panelbaritem and a repeat tag to iterate display a list of records that are returned from an extension class. The repeat tag creates a panelbaritem for each record in the list. All this is displayed in an iframe on the home page. So far so good.

 

The code is working ok since it returns the records it should, also the styles in the style class also are ok since the panelbaritem is colored correctly. BUT the issue comes up in the body of the panelbaritem where the content to display should be a rich text field. The issue is that it is not showing  with the HTML as it should, so where I have a <br> tag im getting the actual <br> in between the text, and so on for all the other html tags and attirbutes.

 

I need to know how I can show the rich text with the correct format in the content part of the panelbaritem. Below is the code to show what Im doing.

 

 

 

//VF PAGE

<apex:page sidebar="False" showHeader="false"  standardcontroller="FrontPageNewsItem__c" extensions="FrontPageNewsItemExt" >
    <style>
    .header
    {
      background-color:#1797C0;
      background-image: none;
      color: white
    }
    .body
    {
     background-color:#B0E0E6;
      background-image: none;
      color: black;
      font-size: 12px;
    }
    .headerActive
    {
      background-color: #1797C0;
      background-image: none;
      color: white;
    }
  </style>
    <apex:panelBar >
        <apex:repeat value="{!FrontPageNewsItems}" var="item"  >
           <apex:panelBarItem label="{!item.Name}"  headerClassActive="headerActive" headerClass="header" contentClass="body" expanded="false" >{!item.Body_Text__c}</apex:panelBarItem>
        </apex:repeat>
    </apex:panelBar>
</apex:page>

 The Body_Text__c field is the rich text field I am wanting to display correctly in SF.

 

THANK YOU!!

 

 

I wrote a web service to connect to a SF org and it should retrieve some account data and then it would do some validations and upload the results into another org. I cannot use S2S since the account structure and workings are way too complex and there are issues. Anyways, my issue is that when I run the code I get an error such as this(highlighted in red):

 

Sforce service created.

Error logging in to Salesforce.com HTTP transport error: java.net.UnknownHostException: login.salesforce.com

Application complete.

 

 

I believe this may have something to do with the fact that I am behind a proxy server, but my problem is that I do not know where do I need to go and edit the code to add the proxy credentials. Below is the code that executes and also the SforceService is instantiated and used to call the login method.

 

 


public Client() {
// upon instantiation invoke process to perform the application logic
doAccountUpdate();
}

// entry point method
public static void main(String[] args) {
new Client();
System.out.println("Application complete.");
}

// this holds the application logic
private void doAccountUpdate() {

// initialize the force.com web services API binding in line with JAX-WS RI
try {
URL wsdlLocation = this.getClass().getClassLoader().getResource("enterprise.wsdl");
if (wsdlLocation == null) {
WebServiceException e = new WebServiceException("enterprise.wsdl not found!");
throw e;
}
// instantiate a new instance of the binding
port = new SforceService(wsdlLocation, new QName("urn:enterprise.soap.sforce.com", "SforceService")).getSoap();


System.out.println("Sforce service created.");
} catch (WebServiceException wse) {
System.out.println("Error creating salesforce port " + wse.getMessage());
}

// initiate a login to salesforce.com
if (doSHSLogin()) {
//do some stuff with accounts
}
}

// this function encapsulates the logic necessary to login to salesforce.com
private boolean doSHSLogin() {
// declare local vars
boolean returnVal = false; // return value
LoginResult loginResponse = null; // object to store the result of the login operation
SessionHeader sh = null; // object to store information about the session
JAXBContext jc = null; // ojbect to provide access to the JAXB API

// These values where set this way for sharing purposes in discussion boards, they are not my real credentials
String userName = "myusername";
String pwd = "mypassword";
String token = "mytoken";


// attempt the login to salesforce.com
try {
loginResponse = port.login(userName, pwd + token);
returnVal = true;

// output some information about the newly created session to the screen
System.out.println("Login was successfull.");
System.out.print("The returned session id is: ");
System.out.println(loginResponse.getSessionId());
System.out.print("Your logged in user id is: ");
System.out.println(loginResponse.getUserId() + " \n\n");

} catch (Exception e) {
System.out.println("Error logging in to Salesforce.com " + e.getMessage());
return false;
}

/* Once the client application has logged in successfully, it will use
* the results of the login call to reset the endpoint of the service
* to the virtual server instance that is servicing your organization
*/
WSBindingProvider bindingProvider = ((WSBindingProvider) port);
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, loginResponse.getServerUrl());

/* The sample client application now has an instance of the SforceService
* that is pointing to the correct endpoint. Next, the sample client
* application sets a persistent SOAP header (to be included on all
* subsequent calls that are made with SforceService) that contains the
* valid sessionId for our login credentials. To do this, the sample
* client application creates a new SessionHeader object and persist it to
* the SforceService. Add the session ID returned from the login to the
* session header
*/
sh = new SessionHeader();
sh.setSessionId(loginResponse.getSessionId());
try {
jc = JAXBContext.newInstance("com.salesforce.sei");
bindingProvider.setOutboundHeaders(Headers.create((JAXBRIContext) jc, sh));
} catch (JAXBException e) {
System.out.println("Error creating JAXBContext instance " + e.getMessage());
return false;
}

//Enable GZip compression for subsequent API requests
Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
httpHeaders.put("Content-Encoding", Collections.singletonList("gzip"));
httpHeaders.put("Accept-Encoding", Collections.singletonList("gzip"));
Map<String, Object> reqContext = bindingProvider.getRequestContext();
reqContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);

// return the result of the attempt to login
return returnVal;
}

}

 This is my SforceService class info

 

 

package com.salesforce.sei;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;


/**
 * Sforce SOAP API
 * 
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */
@WebServiceClient(name = "SforceService", targetNamespace = "urn:enterprise.soap.sforce.com", wsdlLocation = "file:/C:/Documents%20and%20Settings/sg0208508/workspace/integrationTest/src/enterprise.wsdl")
public class SforceService
    extends Service
{

    private final static URL SFORCESERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.salesforce.sei.SforceService.class.getName());

    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl = com.salesforce.sei.SforceService.class.getResource(".");
            url = new URL(baseUrl, "file:/C:/Documents%20and%20Settings/sg0208508/workspace/integrationTest/src/enterprise.wsdl");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/Documents%20and%20Settings/sg0208508/workspace/integrationTest/src/enterprise.wsdl', retrying as a local file");
            logger.warning(e.getMessage());
        }
        SFORCESERVICE_WSDL_LOCATION = url;
    }

    public SforceService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public SforceService() {
        super(SFORCESERVICE_WSDL_LOCATION, new QName("urn:enterprise.soap.sforce.com", "SforceService"));
    }

    /**
     * 
     * @return
     *     returns Soap
     */
    @WebEndpoint(name = "Soap")
    public Soap getSoap() {
        return super.getPort(new QName("urn:enterprise.soap.sforce.com", "Soap"), Soap.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns Soap
     */
    @WebEndpoint(name = "Soap")
    public Soap getSoap(WebServiceFeature... features) {
        return super.getPort(new QName("urn:enterprise.soap.sforce.com", "Soap"), Soap.class, features);
    }

}


 

Can anyone help me shed some light into this issue???

 

Thank you!!

 

 

Hello all,

 

I have a VF page that has a checkbox "send Notification Email" that should send an email when the owner of the record changes. The VF uses an extension controller of the account where I have a EmailChecked property that receives the checkbox state in a action method from the save button on the VF page.

 

Now, have certain actions I want to take when the record changes, such as send the notification email. I want to know how, or if, I can read the EmailChecked property of the extension controller from the trigger to validate whether or not to send the email..

 

(How ) Can this be done?

 

Regards,

 

  • September 28, 2010
  • Like
  • 0

Hello,

 

I have to make a comparison in an if statement that takes two date time field values (Say , createdDate and LastModifiedDate) from two different records. These are values from Historical tables taht track field changes so in essence I am trying to see if tw ofield changes on these two records were made in the same minute.

 

So need a way to take these two date times from these records and see if they have been edited/created within the same minute. 

 

May be an easy fix but I cannot find anything in DateTime documentation.

 

Thank You.!

  • September 07, 2010
  • Like
  • 0

Hello,

 

I have a visualforce page that is supposed toreturn a list of contacts using a controller and some queries. This all is supposed to vary according to the product that is being selected in a picklist above. The problem is that the picklist autopopulates with the correct products but when I select one it does not return any contacts where I know that the selected product has been contracted by an account (via custom object: Participation Details) and that the account has a contact. Yet I get nothing.

 

The idea is that the contactList be rerendered to select the apropiarte contacts when a product is selected. I also need to add a button that will export  the contact list to an excel file, this I have not yet figured out how to do.

 

I have pasted the controller code and the VF code to see if anyone can point out my mistake since I go over it once and again and cannot see where I am flawing. I know it is a little challenging to read all this but I need to complete this and ran out of ideas.

 

 

/*--CONTROLLER CODE--*/

public class contact_fromAcc_by_ProdServ { //constructors    public contact_fromAcc_by_ProdServ(ApexPages.StandardSetController standard) {    }    public contact_fromAcc_by_ProdServ() {    }       public String selectedProduct {get;set;}    public List<Account> accs;    public List<Contact> contacts; public List<Id> pdsAccIds; public Products_Services__c currentProduct;

public class contact_fromAcc_by_ProdServ {
  //constructors    
public contact_fromAcc_by_ProdServ(ApexPages.StandardSetController standard) {    }    
public contact_fromAcc_by_ProdServ() {    }   

public String selectedProduct {get;set;}    
public List<Account> accs;    
public List<Contact> contacts;
 public List<Id> pdsAccIds;
 public Products_Services__c currentProduct;


 // Product/Services Page logic <----
       
    public List<SelectOption> PS_Items {
        get {
            List<selectOption> options = new List<selectOption>();
                options.add(new SelectOption('','-- Choose a Product/Service --'));
                for(Products_Services__c p:[SELECT Id, Name,Type__c from Products_Services__c WHERE P_S_Status__c = 'Active' ORDER BY Type__c ASC]){
this.currentProduct = p;
                    options.add(new SelectOption(p.Name,p.Name));
   }
            return options;}
        set;}



     // Contact Page logic <----  
  public List<Contact> ContactList {get{return contacts;}set;}  

  public void updateContactList() {

  try{
   if (selectedProduct != NULL) {
            //Need to get all the PD for the selectedProduct 
            //pds = [Select p.Account__c From Participation_Detail__c p WHERE p.Product_Service__c = :selectedProduct AND p.Status__c = 'Current' ];
            //Iterate over all the pds and add to a temp account list.
            for(Participation_Detail__c pd: [Select p.Account__c From Participation_Detail__c p WHERE p.Product_Service__c = :selectedProduct AND p.Status__c = 'Current' ])
             { pdsAccIds.add(pd.Account__c);

           if(this.pdsAccIds != null){
           //Get Contact info for accounts in acc list. and set contact info to contacts list.
           this.contacts = [Select c.Subscriptions_SynXis_Selected__c, c.Subscriptions_Customer_Selected__c, c.Id, c.Full_Name__c, c.Fax, c.Email, c.Contact_Type__c, c.AccountId From Contact c WHERE c.No_Longer_with_this_Account__c !=True AND c.EmailBouncedDate = null AND c.AccountId IN:pdsAccIds ];
           }
            }
   }catch (Exception e){
   ApexPages.addMessages(e);
  }
  }

 

 

 

<!--VF page code-->

<apex:page standardController="Contact" extensions="contact_fromAcc_by_ProdServ"   recordSetvar="ContactList" sidebar="false">
    <apex:pageBlock >
        <apex:sectionHeader title="List Contacts from Accounts by Product Service" />
         This page will let you select a Product/Service and it will list all the contacts that are related to accounts that contract that Product/Service via Participation Details. First select
         a Product/Service from the picklist below then wait for the contacts to be calculated and displayed onscreen. Once you can see the contacts, you can permorm regular view actions such as sort,
         export excel file, add/remove fields, etc.
    </apex:pageBlock>
    <br/> 
<!-- Page block to list all ProductServices-->
    <apex:pageBlock >
        <Apex:form >
            <apex:pageBlockSection title="     Active Product Services" showHeader="true" collapsible="false">
               <apex:selectList value="{!selectedProduct}" size="1" multiselect="False" id="products" >
                    <apex:selectOptions value="{!PS_Items}" id="psi"/>
                    <apex:actionSupport event="onchange" action="{!updateContactList}" rerender="contactlist" status="Constatus"/>
                </apex:selectList> 
            </apex:pageBlockSection>
                          
            <apex:pageBlockSection title="     Contacts List" showHeader="true" collapsible="false">
                <apex:actionStatus id="Constatus"> Updating Contact List... </apex:actionStatus>
                Size of the Acc list: <apex:variable value="{!testVarINT}" var="c"/> {!c}
                <apex:actionRegion id="contactRegion">                
                    <apex:dataList var="c" value="{!ContactList }" id="contactlist">
                        {!c.Full_Name__c}                  
                    </apex:dataList>
                </apex:actionRegion>
            </apex:pageBlockSection> 

            <apex:panelGrid columns="2"> 
                <apex:commandLink styleClass="btn" action="{!previous}" rerender="Contactlist">Previous</apex:commandlink><apex:commandLink styleClass="btn" action="{!next}" rerender="Contactlist">Next</apex:commandlink> 
            </apex:panelGrid> 
        </apex:form> 
    </apex:pageBlock>
</apex:page>

 

 

 

 

Thank you !!!!!!

I have several fields in y account page that I need to add a functionality very similar to the account hierarchy page that displays when clicking [view hierarchy].  These fields represent other relationships to other accounts and my users would need to be able to view those relationships in the same way, with parent accounts and even grandparent accounts just like below:

 

click the link from Account 'abc', need to view any accounts at the same level and parent accounts, and any parent of that parent if any.

 

Result: (example) need the indenting and all.

 

Grandpa Account

        Account_1

        Account_2 

        Account_3

        Account_4

        Account_5

        Account_6

        Account_7

        Account_8

        Account abc (this is the Acc. from where we clicked view hierarchy) 

                child acc 1

                child acc 2

                child acc 3

       Account_9

 

Any idea as to how can I achieve this?

Hello,

 

I have added a custom HTML component in the home page with a reference to a  visualforce page I have. The FrontPageNews  object will contain the info I want to show in the page blocks. It needs to be one page block per record. 

I need to iterate over the records and for each one, create a page block with the block title taken from a field in the custom object, and the page section has an outputText tag that would also get the text from a field in the custom object.

 

How can this be achieved? I have no clue how to iterate over objects in visualforce. Much lessdynamically create pageblocks and pageBlockSections.

 

Hello, 

I am trying to add a visualforce page as a home page component to the home page layout. I created the visualforce page and also created  the home page component as n HTML section and added the following code to it:

 


<iframe src="https://cs1.salesforce.com/apex/Front_Page_News" width="100%" height="200px"></iframe>

 

But when I refresh the home page it only shows me the title of the component and the code instead of loading the visualforce page. Can anyone tell me what im doing wrong?

 

Thank you!

I've tried to upload a trigger to sandbox via Eclipse but I get an error stating that the ORG is not enabled for deploying, I also get an error INVALID_TYPE: Cannot create ApexClass. So basically i CAN'T SAVE ANY CHANGES TO SANDBOX.

I've tried all sort of things such as changing the XML to Active ut it won't save the changes to sandbox. I dont know why it is doing this, since I've done all sort of triggers and some coding and never saw this issue in Sandbox, only in production.

 

Can anyone tell me what it is that I am not noticing or need to do?

 

This is the error I get when I try to save the trigger to Sandbox:

 

 

Description Resource Path Location Type
Save error: Not available for deploy for this organization PreventPortalUserOwner2.trigger _SANDBOX Shell Project/src/triggers line 0 Force.com save problem

Description Resource Path Location TypeSave error: Not available for deploy for this organization

 

 

 

 

I have a trigger that needs to use a custom BusinessHours object I created that defines a the valid days and hours for a workgroup that uses the app. The problem I have is that I need to hold the BusinesHours object so that I can use the diff method to calculate the hours of difference between the last status change and the curent status change of another custom object(work order).

 

The code is as follows and the problem is in the "DS_BusinessHours = [SELECT...." line:

 

trigger DS_WO_Stop_Statuses_update on DS_Work_Order__c (after insert, after update) {

 

     

      //Declare vars

      List<Stop_Status__c> StatusList = New List<Stop_Status__c> ();

      BusinessHours DS_BusinessHours = null;

 

//If new Work Order then initialize fields at 0 or equivalent;

if (Trigger.isInsert){

      for(DS_Work_Order__c newWO:System.Trigger.new) {

            newWO.WO_Last_Status_Changed__c= System.now();

            newWO.WO_Time_with_DS__c=0;

     

      }}else{    

//2.get the previous status and it's time and add the

 For (DS_Work_Order__c newWO:System.Trigger.new){

      DS_Work_Order__c oldWO = System.Trigger.oldmap.get(newWO.Id);

       if (oldWo.Status__c!=newWO.Status__c && newWO.WO_Last_Status_Changed__c !=null) {

                  if(newWO.Status__c != 'Pending'){

                        DS_BusinessHours = [SELECT Id From BusinessHours WHERE Name = 'DS_BusinessHours'];

                        Double timeSinceLastStatus = BusinessHours.diff(DS_BusinessHours, newWO.WO_Last_Status_Changed__c, System.now())/3600000.0;

                        newWO.WO_Time_with_DS__c += timeSinceLastStatus;

                        }      

                  }

            }

  }//end else

}//end trigger

 

The problem I get is that im assigning an Id to a business object and then when trying to do the diff method to calculate the difference it throws an exception. My question….How can I get the business hours so I can calculate the diff method?

Please if you have any input I’d appreciate it greatly.

I am needing to integrate salesforce with SAP where I need to push new account information to create the master records. I dont have freedom to add an "SF Id" field to the SAP tables so I'm thinking of using a 2 field combo to identify unique record to and from Salesforce. The problem is that once the information is sent to SAP and it is used to create the master record I need to send the SAP ID back to salesforce and populate a "SAP ID" field in the appropriate account to maintain a reference between them. 

Any ideas as to how I would be able to achieve this?

I want to create my own home page and add my company logo instead of the Salesforce logo. For this I wanted to know what would be the steps. I woudl guess that shoudl be done with a visualforce page, but I dont know how to do it and how do I get the new visualforce page to have the same components as the standard home page.

 

Please help!!

I am trying to setup a dynamic pageblock action on a custom case record type. It is supposed to visualize a pageblock section when the "Billing" value on the "Case Reason" picklist is selected but I get a "Error: Invalid field name for SObject Case" error when trying to quicksave it.

 

The idea is that when in a custom record type, (a case for account administration) you select "Billing" from a "Case reason" picklist, that a pageblock section appears with some fields that are required to be filled.

 

 

Below is the partial code I am creating, but still I have not completed it all. So if you have any ideas  to help me complete it Id be so thankful.

 


<apex:page standardController="Case" sidebar="False">
<apex:sectionHeader title="Billing Training" subtitle="{!Case.name}"/>
<apex:form>
<apex:pageBlock title="Billing Training Details" id="BillingCase_dyn_pgblock" mode="edit">
<apex:pagemessages>
<apex:pageBlockButtons>
<apex:CommandButton value="Save" action="{!save}"/>
<apex:CommandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:actionRegion>
<apex:pageBlockSection title="Case Details"></apex:pageBlockSection>
</apex:actionRegion>
</apex:pagemessages>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Hello,

 

I have a visualforce page exposed in a force.com site. This site is open to the public and guests should be able to access this page through my clients website, a link there would take them to my site. What I need is to pass an IDcode through that link so that when the visualforce page is shown it will have the code in its controller.

 

The idea is that the page is access by many of my clients and each has their own code, this is important so that when creating the controller class I will be using this "Idcode"  to fetch some of the clients data such as rates and availability.

 

How can I do this???

Hello,

 

I am creating a VF page in my org BUT I want to be able to expose it (once completed) in any one of my custromers website (not under the Force.com Sites platform).  

 

The idea is that every customer of mine should be able to see this reservation visualforce page in one of their webpages for their sites. The visualforce page should be able to send information to SF and then retrieve reuslts to which the customer will be able to select one of those results and send it back to SF for creating the custom record.

 

Imagine a hotel with a reservations component calling to SF to get the available rooms based on user input. Then displaying it in the webpage and sending back the selection from the user for processing in SF. This would resoult in a reservation record created in SF and more workflow to fire off.

 

I am not sure how to approach this....Any ideas?

 

 

 

 

can any one tell me how can i bulkify this trigger

trigger pointamount on Opportunity ( after insert,after update,before delete)
 {
 if(trigger.isInsert)
  {
 for (Opportunity  o : Trigger.new)
    {
    if(o.accountid!=null && o.Purchase_Type__c == 'Pilot'&& o.Catalog_Source__c== 'SimCenter')
    {
points__c  a = new Points__c();
a.Account__c = o.Accountid;          
a.Points_Transaction_Amount__c =o.amount-o.amount*2;
a.Points_Transaction_Reason__c =' Points Redeemed';  
a.Points_Transaction_Date__c=o.CloseDate;
a.Purchaser_Email__c=o.Contact_Email__c;
a.Opportunity__c=o.id;
a.Purchaser_Name__c=o.Purchaser_Name__c;
insert a;         


 }
 
 }
 }
 
 
 
 
  if(trigger.isupdate)
   {
  for (Opportunity  o : Trigger.new)
    {
    if(o.accountid!=null && o.Purchase_Type__c == 'Pilot'&& o.Catalog_Source__c== 'SimCenter')
   {
  

     Points__c[] fn =[select id,account__c,opportunity__c from Points__c where opportunity__c=:o.id];
    // fn[0].Points_Transaction_Amount__c=o.amount-o.amount*2;
    // update fn;   
         
 if(fn.size()==0){
 points__c  a = new Points__c();
a.Account__c = o.Accountid;          
a.Points_Transaction_Amount__c =o.amount-o.amount*2;
a.Points_Transaction_Reason__c =' Points Redeemed';  
a.Points_Transaction_Date__c=o.CloseDate;
a.Purchaser_Email__c=o.Contact_Email__c;
a.Opportunity__c=o.id;
a.Purchaser_Name__c=o.Purchaser_Name__c;
insert a;  
}
if(fn.size()>0){  
fn[0].Points_Transaction_Amount__c=o.amount-o.amount*2;
update fn;   
}
 
 
}



}



}
if(trigger.isdelete  )
{
for (Opportunity  o : Trigger.old)
    {
  if(o.accountid!=null &&o.Purchase_Type__c == 'Pilot'&& o.Catalog_Source__c== 'SimCenter')
    {
  

Points__c fn =[select id,account__c,opportunity__c from Points__c where opportunity__c=:o.id  ];

delete fn;
}
}

}




}

 

Hi, 

 

How to make the formula filed required. Please any one help me.

 

 

Thanks,

Lakshmi.

I created a survey using SF sites, and I sent the survey to a few people to test. When they click on the link to the survey, they are taken to a page that says "You are not allowed to fill out this survey."

 

Any suggestions for why this is happening?

 

Thanks so much!

Hello,

 

Could anyone assist me with the following issue I have:

 

I have created an apex class that does some querying of accounts and custom objects in preparation to making a query for the related contact records. Basically I have a Product/services object that is referenced in a PArticipation Details object that is in turn referenced in an Account. Therefore the class would return ALL contacts at the accounts for a certain Product/Service.

Since some of those product/services are very famous, there are some that return over 10,000 contacts and for that reason, that part of the querying must be done in an apex batch job.

 

I have debugged the results and the contacts list is updated with the scope list in the execute method, BUt for some reason the visualforce page is not updated with the resulting list. Below is the code of the visualforce page and the controller:

 

 

global class contact_fromAcc_by_ProdServ implements Database.Batchable<sObject> {
   
    VRDbg.VRDebugLogger vrdl = new VRDbg.VRDebugLogger();
    public Id selectedProduct {get;set;}
    public List<Account> accs;
    private List<Contact> contacts= new List<Contact>();
    public List<Id> pdsAccIds = null;
    public Products_Services__c currentProduct;   
    public List<Participation_Detail__c> tempPDList;
    public List<Contact> ContactList {get{return contacts;}set;} 
    
    //constructors
    public contact_fromAcc_by_ProdServ(ApexPages.StandardController standard) {
    }
    public contact_fromAcc_by_ProdServ() {
    }         
    
    //Product Service List objects - PROPERTY
    public List<SelectOption> PS_Items {
        get {
            List<selectOption> options = new List<selectOption>();
            options.add(new SelectOption('','-- Choose a Product/Service --'));
            for(Products_Services__c p: [SELECT Id, Name,Type__c from Products_Services__c WHERE P_S_Status__c = 'Active' ORDER BY Name ASC]){
               // this.currentProduct = p;
                options.add(new SelectOption(p.Id,p.Name));
                selectedProduct = p.Id;}
                return options;
            }
        set;}
   
 

    //Method to calculate contact list
public void updateContactList() {        
        if (selectedProduct != NULL) {
            pdsAccIds = new List<Id>();
            tempPDList = [Select p.Account__c 
                          From Participation_Detail__c p 
                          WHERE p.Product_Service__c = :selectedProduct AND p.Status__c = 'Current'];
            //get Account Ids in temp PD list.
             for(Participation_Detail__c pd: tempPDList){
                if(pd.Account__c != null){
                   pdsAccIds.add(pd.Account__c); 
                }
            }
            //execute batch job to get contact data from Account listing.
            if(this.pdsAccIds != null){
                Database.executeBatch(this, 50000);
                ContactList = contacts;
            }
      }
    }//end method
    
      
      public void clearList (){
        this.contacts.clear();
        //this.contacts = null;
      }
      
      //////// Mandatory implementation of Batchable processes interface to retrieve contacts from SF
     global Database.queryLocator start (Database.BatchableContext ctx){
        return Database.getQueryLocator([SELECT
                                                c.Id, c.Full_Name__c, c.AccountId , 
                                                c.Account.Master_Account_Status__c , c.Account.Sub_Status_IMS__c, 
                                                c.Account.SubStatusSynXisCRS__c, c.Account.Sub_Status_Sabre_GDS__c, 
                                                c.Account.Sub_Status_Hotel_RFP__c, c.Account.Sub_Status_Internal__c , 
                                                c.Contact_Type__c, c.Email, c.HasOptedOutOfEmail, c.Subscriptions_SynXis_Selected__c, 
                                                c.Subscriptions_Customer_Selected__c 
                                        FROM Contact c 
                                        WHERE 
                                                c.No_Longer_with_this_Account__c !=True 
                                                AND c.EmailBouncedDate = null 
                                                AND Account.Id IN:pdsAccIds ]);
    }
    
    global void execute(Database.BatchableContext BC, list<Contact> scope){
        for(Contact con:scope){
            this.contacts.add(con);
        }
         vrdl.logIt('Contacts list size: ' + contacts.size() + ' || Scope list size: ' + scope.size() + 'ContactList method: ' + ContactList);
         vrdl.send();
    }
    
    global void finish(Database.BatchableContext BC){} 
      
    
}//end class

 and the visualforce page:

 

<!--Product/service name 
Account Owner (when AM is the Account Owner) 
Instead of Full Name make link to Contact record? 
Add Sub-Status fields 
Take out Fax field 
Email Opt Out? 
Maybe a link to the Participation Detail record?-->
 
<apex:page tabStyle="Products_Services__c"   controller="contact_fromAcc_by_ProdServ" pageStyle="Contact"  sidebar="false" standardStylesheets="true" showHeader="false" >  
<apex:pageBlock >
        <apex:sectionHeader /> 
        <font color="black" size="5" align="center">Contacts @ Accounts by Product Service</font><br/><br/>
         This page will let you select a Product/Service and it will list all the contacts that are related to accounts that contract that Product/Service via Participation Details. First select
         a Product/Service from the picklist below then wait for the contacts to be calculated and displayed onscreen. Once you can see the contacts, you can permorm regular view actions such as sort,
         export excel file, add/remove fields, etc.        
    </apex:pageBlock>
    <br/> 
<!-- Page block to list all ProductServices-->
<apex:pageBlock >
    <apex:form >
        <apex:pageBlockSection title="     Active Product Services" showHeader="true" collapsible="false" dir="" columns="2">
               <apex:selectList value="{!selectedProduct}" size="1" multiselect="False" id="products" >
                   <apex:selectOptions value="{!PS_Items}" id="psi"/>
               </apex:selectList>
               <apex:commandButton action="{!updateContactList}" rerender="contactlist" status="Constatus" title="Click to update Contact list" value="Update Contact List" /> 
        </apex:pageBlockSection>
        <apex:pageBlockSection title=" Contacts List" showHeader="true" collapsible="false">
                <apex:pageBlockSectionItem >
                    <apex:commandButton value="Export to Excel" action="/apex/contacts_romAcc_by_ProdServ_EXCELexport"/>   
                </apex:pageBlockSectionItem> 
                <apex:pageBlockSectionItem >
                    <apex:actionStatus id="Constatus">
                        <apex:facet name="start" >'Updating Contact List...'</apex:facet>
                    </apex:actionStatus>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
           <br/>
            <apex:pageBlockSection >
               <apex:outputPanel id="contactlist" >
                  <apex:pageBlockTable width="100" value="{!ContactList}" var="c" id="dt" >
                     <apex:column >
                         <apex:facet name="header">Full Name</apex:facet>
                         <apex:outputLink value="/{!c.Id}" target="_blank">{!c.Full_Name__c}</apex:outputLink>
                     </apex:column>

                     <apex:column value="{!c.AccountId}" width="250">
                         <apex:facet name="header">  Account Name  </apex:facet>
                     </apex:column>              

                     <apex:column value="{!c.Account.Master_Account_Status__c}">
                         <apex:facet name="header">Account Master Status</apex:facet>
                     </apex:column>                    

                    <apex:column value="{!c.Account.SubStatusSynXisCRS__c}">
                         <apex:facet name="header">Sub Status Synxis CRS</apex:facet>
                     </apex:column>                    

                    <apex:column value="{!c.Account.Sub_Status_Sabre_GDS__c }">
                         <apex:facet name="header">Sub Status Sabre GDS</apex:facet>
                     </apex:column>  
                      <apex:column value="{!c.Account.Sub_Status_Hotel_RFP__c}">
                         <apex:facet name="header">Sub Status Hotel RFP</apex:facet>
                     </apex:column>
                     <apex:column value="{!c.Account.Sub_Status_IMS__c}">
                         <apex:facet name="header">Subscriptions - Customer Selected</apex:facet>
                     </apex:column> 
                      <apex:column value="{!c.Subscriptions_SynXis_Selected__c}">
                         <apex:facet name="header">Subscriptions - Synxis Selected</apex:facet>
                     </apex:column>
                      <apex:column value="{!c.Subscriptions_Customer_Selected__c}">
                         <apex:facet name="header">Subscriptions - Customer Selected</apex:facet>
                     </apex:column>                                 
                      <apex:column value="{!c.HasOptedOutOfEmail}">
                         <apex:facet name="header">Email Opt Out</apex:facet>
                     </apex:column>     
             </apex:pageBlockTable>             
             </apex:outputPanel>
         </apex:pageBlockSection> 
           <br/> 
         <apex:pageBlockSection >
             <apex:panelGrid columns="3"> 
                 <apex:commandButton value="Export to Excel" action="/apex/contacts_romAcc_by_ProdServ_EXCELexport"/>
                 <apex:outputLabel style="color:#404040;"> ***IMPORTANT: Due to SF restrictions, the EXPORT TO EXCEL button only works with  the Google CHROME or Mozilla FIREFOX browsers. If it is run from IE6/7 it will NOT download the excel file.***
</apex:outputLabel>
             </apex:panelGrid> 
         </apex:pageBlockSection>
     </apex:form>
</apex:pageBlock>
</apex:page>

 

 

Thank you!!!

 

I have a trigger that works on a custom object called Sales Credit Detail and is supposed to add a sharing to theOpportunity owner (which is a related object via lookup).

 

Our org wide default for this Sales Credit object is Private and not using hierarchies to grant access. The idea is that ONLY the sales credit detail owner AND the opportunity owner can edit the sales credit detail (from now on SCD) record. An Opportunity can have many SCDs and for each the owner of that record gets default FULL access, BUT also for each of these I want to add the Opportunity owner to be able to have full access to it as well.

 

I decided to add a trigger that would add a share to the SCD for the Opp owner BUT when I edit the SCD record, the rule is not created for the Opportunity owner. BElow is the code, can someone see if I am failing somewhere? I cannot figure it out. I have tested the list sizes and the opp owner etc and they all give the correct value, so I dont know why it is not working

 

 

trigger Opportunity_Owner_share on Sales_Credit_Detail__c (after insert, after update) {
    //Create list of sharing records to create for SCDs in api call. 
    List<Sales_Credit_Detail__Share> SCD_Shares = new List<Sales_Credit_Detail__Share>();
    List<Sales_Credit_Detail__c> SCDS;
   
   //get all Opportunities for all SCD that will be inserted.
   List<Opportunity> opps = [SELECT Id, OwnerId, Name From Opportunity Where Id IN(SELECT ParentOpportunity__c From Sales_Credit_Detail__c Where Id IN :Trigger.newMap.keyset())];
   System.Debug(opps.size());
   
   //For each SCD record being inserted/edited, create a sharing record to the Opportunity owner of that SCD
    for(Sales_Credit_Detail__c scd: Trigger.new){
	   Sales_Credit_Detail__Share scd_share = new Sales_Credit_Detail__Share();
	   scd_share.ParentId = scd.Id;
	   scd_share.AccessLevel = 'All';
	   scd_share.RowCause = Schema.Sales_Credit_Detail__share.RowCause.Opportunity_Owner_Access__c;
	   System.Debug(scd_share.RowCause);
	  
	   for(Opportunity o:opps){
	   	//Add share record to list of shares to upload IF not for Opp Owner same as SCD owner
	       if(o.Id == scd.ParentOpportunity__c && o.OwnerId != scd.OwnerId){
	           scd_share.UserOrGroupId = o.OwnerId;
	           }       	
	       }
	    // Add the new Share record to the list of new Share records.
	    SCD_Shares.add(scd_share);
	    System.Debug(SCD_Shares);
        }
        //Insert all shares to the Database.
        Try{
         insert(SCD_Shares);
        }catch (Exception e){
        	System.Debug(e);
        }
}

 

 

 

I keep getting a System.QueryException: List has no rows for assignment to SObject  exception for a trigger I created. I am not sure how to solve the issue, can anyone help????

 

 

trigger CalculateTotalBonusPercentageNEW on Sales_Credit_Detail__c (before insert, before update) {

    //Declaring Global Variables
    map<Id, Commission__c> currentCommissionsMap = new map<Id, Commission__c>();
    Id oppOwnerId;
    Account OppAcc;
    Sales_Goal__c sg;
    Boolean test = true;
    String probando;
    
    // get all current commissions      
    for(Commission__c c : [Select Id, Accelerator__c, End_Date__c, Start_Date__c From Commission__c Where Start_Date__c <= :System.today() AND End_Date__c >= :System.today()])
      {	currentCommissionsMap.put(c.Id, c);}
    
    for (Sales_Credit_Detail__c scd : trigger.new){
    	Id scr = scd.Sales_Credit_Recipient__c;
    	
    	//if trigger is insert then change owner to SCR.
        if(Trigger.IsInsert){scd.OwnerId = scr ;}
        
        //Map the SCD's Opportunity to a variable
        Opportunity o = [SELECT Id, AccountId,CloseDate,Type,CommPerN__c,StageName,Name,New_Business_Type__c 
                                From Opportunity where ID = :scd.ParentOpportunity__c LIMIT 1];
                                System.Debug(o);
       try{ 
            // get sales goal for SCD Recipient. Check currentCommissionsMap is not null.
            if( currentCommissionsMap.isEmpty()){
            	test = false;
            }else{
                  sg = [select Met_Date__c, User__c, Commission__r.Accelerator__c 
                        From Sales_Goal__c 
                        Where User__c = :scr  AND Commission__c IN :currentCommissionsMap.keySet() LIMIT 1];
            }           
            if( sg == Null){test = false;}
            
            //validate if account region and Opp parameters are correct, if so write to total bonus Percentage with extra kicker, else write only Commission Percent New value
          if(test == true){
                if (sg.Met_Date__c != null &&  o.CloseDate >= sg.Met_Date__c &&
                 o.Type == 'New Business' && 
                 o.StageName == 'Closed Won' && 
                 (o.New_Business_Type__c.equalsIgnoreCase('New Account') || 
                 o.New_Business_Type__c.equalsIgnoreCase('Add Prop Existing Acct') || 
                 o.New_Business_Type__c.equalsIgnoreCase('Add Prod/Srvcs Existing Acct') || 
                 scd.ParentOpportunity__r.New_Business_Type__c.equalsIgnoreCase('Parent/Chain/Partner Switch')) 
                 ){
                    Decimal accelerator = (sg.Commission__r.Accelerator__c > 0) ? sg.Commission__r.Accelerator__c : 0;
                    scd.zCommAccel__c = accelerator;
                    scd.Total_Bonus_Percentage__c = o.CommPerN__c + accelerator;
                   }
           } else {
                    scd.zCommAccel__c = 0;
                    scd.Total_Bonus_Percentage__c = o.CommPerN__c;
            }
                 
       }catch (Exception e){
            scd.addError( e + ' Test:' +  test + '  /' + ' sg:'+  sg);
            // 'There was a problem when saving your Sales Credit Detail record. Please validate that the Opportunity values are correct or that the User has a sales Goal and that the Met Date is less than the Opportunity Close Date.'   
       }
    }
}

 

 

Hello,

 

I have a home page component that displays text from a field in a custom object called FrontPageNews. The idea is to load into the component the latest news we have in our org.

 

What I did was to create a VF page that uses a panelbaritem and a repeat tag to iterate display a list of records that are returned from an extension class. The repeat tag creates a panelbaritem for each record in the list. All this is displayed in an iframe on the home page. So far so good.

 

The code is working ok since it returns the records it should, also the styles in the style class also are ok since the panelbaritem is colored correctly. BUT the issue comes up in the body of the panelbaritem where the content to display should be a rich text field. The issue is that it is not showing  with the HTML as it should, so where I have a <br> tag im getting the actual <br> in between the text, and so on for all the other html tags and attirbutes.

 

I need to know how I can show the rich text with the correct format in the content part of the panelbaritem. Below is the code to show what Im doing.

 

 

 

//VF PAGE

<apex:page sidebar="False" showHeader="false"  standardcontroller="FrontPageNewsItem__c" extensions="FrontPageNewsItemExt" >
    <style>
    .header
    {
      background-color:#1797C0;
      background-image: none;
      color: white
    }
    .body
    {
     background-color:#B0E0E6;
      background-image: none;
      color: black;
      font-size: 12px;
    }
    .headerActive
    {
      background-color: #1797C0;
      background-image: none;
      color: white;
    }
  </style>
    <apex:panelBar >
        <apex:repeat value="{!FrontPageNewsItems}" var="item"  >
           <apex:panelBarItem label="{!item.Name}"  headerClassActive="headerActive" headerClass="header" contentClass="body" expanded="false" >{!item.Body_Text__c}</apex:panelBarItem>
        </apex:repeat>
    </apex:panelBar>
</apex:page>

 The Body_Text__c field is the rich text field I am wanting to display correctly in SF.

 

THANK YOU!!

 

 

I wrote a web service to connect to a SF org and it should retrieve some account data and then it would do some validations and upload the results into another org. I cannot use S2S since the account structure and workings are way too complex and there are issues. Anyways, my issue is that when I run the code I get an error such as this(highlighted in red):

 

Sforce service created.

Error logging in to Salesforce.com HTTP transport error: java.net.UnknownHostException: login.salesforce.com

Application complete.

 

 

I believe this may have something to do with the fact that I am behind a proxy server, but my problem is that I do not know where do I need to go and edit the code to add the proxy credentials. Below is the code that executes and also the SforceService is instantiated and used to call the login method.

 

 


public Client() {
// upon instantiation invoke process to perform the application logic
doAccountUpdate();
}

// entry point method
public static void main(String[] args) {
new Client();
System.out.println("Application complete.");
}

// this holds the application logic
private void doAccountUpdate() {

// initialize the force.com web services API binding in line with JAX-WS RI
try {
URL wsdlLocation = this.getClass().getClassLoader().getResource("enterprise.wsdl");
if (wsdlLocation == null) {
WebServiceException e = new WebServiceException("enterprise.wsdl not found!");
throw e;
}
// instantiate a new instance of the binding
port = new SforceService(wsdlLocation, new QName("urn:enterprise.soap.sforce.com", "SforceService")).getSoap();


System.out.println("Sforce service created.");
} catch (WebServiceException wse) {
System.out.println("Error creating salesforce port " + wse.getMessage());
}

// initiate a login to salesforce.com
if (doSHSLogin()) {
//do some stuff with accounts
}
}

// this function encapsulates the logic necessary to login to salesforce.com
private boolean doSHSLogin() {
// declare local vars
boolean returnVal = false; // return value
LoginResult loginResponse = null; // object to store the result of the login operation
SessionHeader sh = null; // object to store information about the session
JAXBContext jc = null; // ojbect to provide access to the JAXB API

// These values where set this way for sharing purposes in discussion boards, they are not my real credentials
String userName = "myusername";
String pwd = "mypassword";
String token = "mytoken";


// attempt the login to salesforce.com
try {
loginResponse = port.login(userName, pwd + token);
returnVal = true;

// output some information about the newly created session to the screen
System.out.println("Login was successfull.");
System.out.print("The returned session id is: ");
System.out.println(loginResponse.getSessionId());
System.out.print("Your logged in user id is: ");
System.out.println(loginResponse.getUserId() + " \n\n");

} catch (Exception e) {
System.out.println("Error logging in to Salesforce.com " + e.getMessage());
return false;
}

/* Once the client application has logged in successfully, it will use
* the results of the login call to reset the endpoint of the service
* to the virtual server instance that is servicing your organization
*/
WSBindingProvider bindingProvider = ((WSBindingProvider) port);
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, loginResponse.getServerUrl());

/* The sample client application now has an instance of the SforceService
* that is pointing to the correct endpoint. Next, the sample client
* application sets a persistent SOAP header (to be included on all
* subsequent calls that are made with SforceService) that contains the
* valid sessionId for our login credentials. To do this, the sample
* client application creates a new SessionHeader object and persist it to
* the SforceService. Add the session ID returned from the login to the
* session header
*/
sh = new SessionHeader();
sh.setSessionId(loginResponse.getSessionId());
try {
jc = JAXBContext.newInstance("com.salesforce.sei");
bindingProvider.setOutboundHeaders(Headers.create((JAXBRIContext) jc, sh));
} catch (JAXBException e) {
System.out.println("Error creating JAXBContext instance " + e.getMessage());
return false;
}

//Enable GZip compression for subsequent API requests
Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
httpHeaders.put("Content-Encoding", Collections.singletonList("gzip"));
httpHeaders.put("Accept-Encoding", Collections.singletonList("gzip"));
Map<String, Object> reqContext = bindingProvider.getRequestContext();
reqContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);

// return the result of the attempt to login
return returnVal;
}

}

 This is my SforceService class info

 

 

package com.salesforce.sei;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;


/**
 * Sforce SOAP API
 * 
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */
@WebServiceClient(name = "SforceService", targetNamespace = "urn:enterprise.soap.sforce.com", wsdlLocation = "file:/C:/Documents%20and%20Settings/sg0208508/workspace/integrationTest/src/enterprise.wsdl")
public class SforceService
    extends Service
{

    private final static URL SFORCESERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.salesforce.sei.SforceService.class.getName());

    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl = com.salesforce.sei.SforceService.class.getResource(".");
            url = new URL(baseUrl, "file:/C:/Documents%20and%20Settings/sg0208508/workspace/integrationTest/src/enterprise.wsdl");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: 'file:/C:/Documents%20and%20Settings/sg0208508/workspace/integrationTest/src/enterprise.wsdl', retrying as a local file");
            logger.warning(e.getMessage());
        }
        SFORCESERVICE_WSDL_LOCATION = url;
    }

    public SforceService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public SforceService() {
        super(SFORCESERVICE_WSDL_LOCATION, new QName("urn:enterprise.soap.sforce.com", "SforceService"));
    }

    /**
     * 
     * @return
     *     returns Soap
     */
    @WebEndpoint(name = "Soap")
    public Soap getSoap() {
        return super.getPort(new QName("urn:enterprise.soap.sforce.com", "Soap"), Soap.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns Soap
     */
    @WebEndpoint(name = "Soap")
    public Soap getSoap(WebServiceFeature... features) {
        return super.getPort(new QName("urn:enterprise.soap.sforce.com", "Soap"), Soap.class, features);
    }

}


 

Can anyone help me shed some light into this issue???

 

Thank you!!

 

 

Hello all,

 

I have a VF page that has a checkbox "send Notification Email" that should send an email when the owner of the record changes. The VF uses an extension controller of the account where I have a EmailChecked property that receives the checkbox state in a action method from the save button on the VF page.

 

Now, have certain actions I want to take when the record changes, such as send the notification email. I want to know how, or if, I can read the EmailChecked property of the extension controller from the trigger to validate whether or not to send the email..

 

(How ) Can this be done?

 

Regards,

 

  • September 28, 2010
  • Like
  • 0

Hello,

 

I have a visualforce page that is supposed toreturn a list of contacts using a controller and some queries. This all is supposed to vary according to the product that is being selected in a picklist above. The problem is that the picklist autopopulates with the correct products but when I select one it does not return any contacts where I know that the selected product has been contracted by an account (via custom object: Participation Details) and that the account has a contact. Yet I get nothing.

 

The idea is that the contactList be rerendered to select the apropiarte contacts when a product is selected. I also need to add a button that will export  the contact list to an excel file, this I have not yet figured out how to do.

 

I have pasted the controller code and the VF code to see if anyone can point out my mistake since I go over it once and again and cannot see where I am flawing. I know it is a little challenging to read all this but I need to complete this and ran out of ideas.

 

 

/*--CONTROLLER CODE--*/

public class contact_fromAcc_by_ProdServ { //constructors    public contact_fromAcc_by_ProdServ(ApexPages.StandardSetController standard) {    }    public contact_fromAcc_by_ProdServ() {    }       public String selectedProduct {get;set;}    public List<Account> accs;    public List<Contact> contacts; public List<Id> pdsAccIds; public Products_Services__c currentProduct;

public class contact_fromAcc_by_ProdServ {
  //constructors    
public contact_fromAcc_by_ProdServ(ApexPages.StandardSetController standard) {    }    
public contact_fromAcc_by_ProdServ() {    }   

public String selectedProduct {get;set;}    
public List<Account> accs;    
public List<Contact> contacts;
 public List<Id> pdsAccIds;
 public Products_Services__c currentProduct;


 // Product/Services Page logic <----
       
    public List<SelectOption> PS_Items {
        get {
            List<selectOption> options = new List<selectOption>();
                options.add(new SelectOption('','-- Choose a Product/Service --'));
                for(Products_Services__c p:[SELECT Id, Name,Type__c from Products_Services__c WHERE P_S_Status__c = 'Active' ORDER BY Type__c ASC]){
this.currentProduct = p;
                    options.add(new SelectOption(p.Name,p.Name));
   }
            return options;}
        set;}



     // Contact Page logic <----  
  public List<Contact> ContactList {get{return contacts;}set;}  

  public void updateContactList() {

  try{
   if (selectedProduct != NULL) {
            //Need to get all the PD for the selectedProduct 
            //pds = [Select p.Account__c From Participation_Detail__c p WHERE p.Product_Service__c = :selectedProduct AND p.Status__c = 'Current' ];
            //Iterate over all the pds and add to a temp account list.
            for(Participation_Detail__c pd: [Select p.Account__c From Participation_Detail__c p WHERE p.Product_Service__c = :selectedProduct AND p.Status__c = 'Current' ])
             { pdsAccIds.add(pd.Account__c);

           if(this.pdsAccIds != null){
           //Get Contact info for accounts in acc list. and set contact info to contacts list.
           this.contacts = [Select c.Subscriptions_SynXis_Selected__c, c.Subscriptions_Customer_Selected__c, c.Id, c.Full_Name__c, c.Fax, c.Email, c.Contact_Type__c, c.AccountId From Contact c WHERE c.No_Longer_with_this_Account__c !=True AND c.EmailBouncedDate = null AND c.AccountId IN:pdsAccIds ];
           }
            }
   }catch (Exception e){
   ApexPages.addMessages(e);
  }
  }

 

 

 

<!--VF page code-->

<apex:page standardController="Contact" extensions="contact_fromAcc_by_ProdServ"   recordSetvar="ContactList" sidebar="false">
    <apex:pageBlock >
        <apex:sectionHeader title="List Contacts from Accounts by Product Service" />
         This page will let you select a Product/Service and it will list all the contacts that are related to accounts that contract that Product/Service via Participation Details. First select
         a Product/Service from the picklist below then wait for the contacts to be calculated and displayed onscreen. Once you can see the contacts, you can permorm regular view actions such as sort,
         export excel file, add/remove fields, etc.
    </apex:pageBlock>
    <br/> 
<!-- Page block to list all ProductServices-->
    <apex:pageBlock >
        <Apex:form >
            <apex:pageBlockSection title="     Active Product Services" showHeader="true" collapsible="false">
               <apex:selectList value="{!selectedProduct}" size="1" multiselect="False" id="products" >
                    <apex:selectOptions value="{!PS_Items}" id="psi"/>
                    <apex:actionSupport event="onchange" action="{!updateContactList}" rerender="contactlist" status="Constatus"/>
                </apex:selectList> 
            </apex:pageBlockSection>
                          
            <apex:pageBlockSection title="     Contacts List" showHeader="true" collapsible="false">
                <apex:actionStatus id="Constatus"> Updating Contact List... </apex:actionStatus>
                Size of the Acc list: <apex:variable value="{!testVarINT}" var="c"/> {!c}
                <apex:actionRegion id="contactRegion">                
                    <apex:dataList var="c" value="{!ContactList }" id="contactlist">
                        {!c.Full_Name__c}                  
                    </apex:dataList>
                </apex:actionRegion>
            </apex:pageBlockSection> 

            <apex:panelGrid columns="2"> 
                <apex:commandLink styleClass="btn" action="{!previous}" rerender="Contactlist">Previous</apex:commandlink><apex:commandLink styleClass="btn" action="{!next}" rerender="Contactlist">Next</apex:commandlink> 
            </apex:panelGrid> 
        </apex:form> 
    </apex:pageBlock>
</apex:page>

 

 

 

 

Thank you !!!!!!

I have several fields in y account page that I need to add a functionality very similar to the account hierarchy page that displays when clicking [view hierarchy].  These fields represent other relationships to other accounts and my users would need to be able to view those relationships in the same way, with parent accounts and even grandparent accounts just like below:

 

click the link from Account 'abc', need to view any accounts at the same level and parent accounts, and any parent of that parent if any.

 

Result: (example) need the indenting and all.

 

Grandpa Account

        Account_1

        Account_2 

        Account_3

        Account_4

        Account_5

        Account_6

        Account_7

        Account_8

        Account abc (this is the Acc. from where we clicked view hierarchy) 

                child acc 1

                child acc 2

                child acc 3

       Account_9

 

Any idea as to how can I achieve this?

Hello,

 

I have added a custom HTML component in the home page with a reference to a  visualforce page I have. The FrontPageNews  object will contain the info I want to show in the page blocks. It needs to be one page block per record. 

I need to iterate over the records and for each one, create a page block with the block title taken from a field in the custom object, and the page section has an outputText tag that would also get the text from a field in the custom object.

 

How can this be achieved? I have no clue how to iterate over objects in visualforce. Much lessdynamically create pageblocks and pageBlockSections.

 

Hello, 

I am trying to add a visualforce page as a home page component to the home page layout. I created the visualforce page and also created  the home page component as n HTML section and added the following code to it:

 


<iframe src="https://cs1.salesforce.com/apex/Front_Page_News" width="100%" height="200px"></iframe>

 

But when I refresh the home page it only shows me the title of the component and the code instead of loading the visualforce page. Can anyone tell me what im doing wrong?

 

Thank you!

I've tried to upload a trigger to sandbox via Eclipse but I get an error stating that the ORG is not enabled for deploying, I also get an error INVALID_TYPE: Cannot create ApexClass. So basically i CAN'T SAVE ANY CHANGES TO SANDBOX.

I've tried all sort of things such as changing the XML to Active ut it won't save the changes to sandbox. I dont know why it is doing this, since I've done all sort of triggers and some coding and never saw this issue in Sandbox, only in production.

 

Can anyone tell me what it is that I am not noticing or need to do?

 

This is the error I get when I try to save the trigger to Sandbox:

 

 

Description Resource Path Location Type
Save error: Not available for deploy for this organization PreventPortalUserOwner2.trigger _SANDBOX Shell Project/src/triggers line 0 Force.com save problem

Description Resource Path Location TypeSave error: Not available for deploy for this organization

 

 

 

 

I am trying to setup a dynamic pageblock action on a custom case record type. It is supposed to visualize a pageblock section when the "Billing" value on the "Case Reason" picklist is selected but I get a "Error: Invalid field name for SObject Case" error when trying to quicksave it.

 

The idea is that when in a custom record type, (a case for account administration) you select "Billing" from a "Case reason" picklist, that a pageblock section appears with some fields that are required to be filled.

 

 

Below is the partial code I am creating, but still I have not completed it all. So if you have any ideas  to help me complete it Id be so thankful.

 


<apex:page standardController="Case" sidebar="False">
<apex:sectionHeader title="Billing Training" subtitle="{!Case.name}"/>
<apex:form>
<apex:pageBlock title="Billing Training Details" id="BillingCase_dyn_pgblock" mode="edit">
<apex:pagemessages>
<apex:pageBlockButtons>
<apex:CommandButton value="Save" action="{!save}"/>
<apex:CommandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:actionRegion>
<apex:pageBlockSection title="Case Details"></apex:pageBlockSection>
</apex:actionRegion>
</apex:pagemessages>
</apex:pageBlock>
</apex:form>
</apex:page>

 

hi all,
 
i got an error message saying : request failed with http status 407: proxy authentication required(ISA server requires authorization to fulfill the request. access to the web proxy filter is denied )
whenever i try to run apex explorer.
 
what changes should i make into tools-> options to make it run properly?
 
thanks,
mahi
  • November 14, 2007
  • Like
  • 0