• Matt Smelser
  • NEWBIE
  • 220 Points
  • Member since 2014

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 36
    Replies
Hello,

On the object case i have a field called "Case owner", this field is a look up.

this lookup can be "queue" or "user".

How can i know that if it is a "queue" or "user" in Apex ?

thanks for suggestions.
  • December 15, 2016
  • Like
  • 0
Hi,

I want to be able to populate a custom Case field with the data held in 'Assigned To' when you submt for approval.

So, when I press 'Submit for Approval' it is assigned to a User or a queue. I want a trigger that puts that info into a custom text field so that I can create a Cases list from it to see what is in a person 'waiting for approval' queue.

Is that possible?

Thanks

Matt
Hello,

How to display currency in particular format($3,000.00) in Visualforce page and also in standard page layouts ?
 
  • November 10, 2016
  • Like
  • 0
Hi,

I am trying to write a trigger that will update a custom field that I created on the opportunity object called case status. It is a picklist field that I want to mirror the status picklist field on cases. I also created a lookup field on opportunities called related_case. The related_case field ties the two objects together. Right now my trigger works so that after i update the field on cases I then have to press edit and save on the opportunity page to get the field to update. What I would like to happen is have the opportunity page update on refresh after changing the case field. The trigger is currently built on the opportunity and I am thinking maybe it needs to be built on the case instead. 

I am attaching the code here and any help or advice is greatly appreciated.
 
trigger updateCaseStatus on Opportunity(After Update) {

      set<id> setid =new set<id>();
    
    for(Opportunity Opp: Trigger.new){
        if(Opp.Related_Case__c != null)
        {
        setid.add(Opp.Related_Case__c);
        }
     Case cas = [select id,Status from Case where Id in: setid];
     
              for(Opportunity Opps : trigger.new)
       {
              
          Opps.Case_Status__c= cas.Status;
          opps.Related_case__c = cas.id;

             }

   }
   }




Thanks,

Edward
I have created a Visualforce page with a custom controller that is essentially a search page that I've embedded within the Lead page.  It gives my users the ability to quickly search for duplicates without leaving the page.  The issue is, I'm trying to figure out how to prepopulate the search, so they don't have to copy the email address to the search bar.

Here's the Controller:

Public with sharing class LeadOppsearchclas{
 Public List<Lead>leadList{get;set;}
 Public List<Opportunity>optyList{get;set;}
   Public String searchStr{get;set;}
   Public LeadOppsearchclas(){
   }
 
 public LeadOppsearchclas(ApexPages.StandardController stdController){
 }
 
    Public void soslDemo_method(){
       leadList = New List<Lead>();
   optyList = New List<Opportunity>();
   
   if(searchStr.length() > 1){
   String searchStr1 = '*'+searchStr+'*';
   String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Lead (Id,Name,Email,metro__c,statusname__c,Listing_MLS__c,date_entered_into_Lead_router__c,listing_amount__c,listing_agent__c,referral_fee__c,last_activity_subject__c),Opportunity(Id,Name,Account_Email__c,Opportunity_EMail__c,metro__c,statusname__c,Owner_Name__c,date_entered_into_Lead_router__c,listing_amount__c,listing_agent__c,agent__c,referral_fee__c,last_activity_subject__c)';
   List<List <sObject>> searchList = search.query(searchQuery);
   leadList = ((List<Lead>)searchList[0]);
      optyList = ((List<Opportunity>)searchList[1]);
   if(leadList.size() == 0 && optyList.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, no results returned with matching string..'));
       return;
   }
   }
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter at least two characters..'));
   return;
   }
  }
}

And the Visualforce Page:

<apex:page standardcontroller="Lead" extensions="LeadOppsearchclas">
  <apex:form >
  <apex:inputText value="{!searchStr}"/>
    <apex:commandButton value="Search in Lead, Opportunity" action="{!soslDemo_method}"                reRender="lead,error,oppt" status="actStatusId"/>
    <apex:actionStatus id="actStatusId">
                <apex:facet name="start" >
                    <img src="/img/loading.gif"/>                    
                </apex:facet>
    </apex:actionStatus>
  </apex:form>
 
    <apex:outputPanel title="" id="error">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
 
 <apex:pageBlock title="Opportunities" id="oppt">
    <apex:pageblockTable value="{!optyList}" var="opty">
     <apex:column headervalue="Name"><apex:outputLink value="/{!opty.ID}" target="_blank">{!opty.name}</apex:outputLink></apex:column>
     <apex:column value="{!opty.Account_Email__c}"/>
     <apex:column value="{!opty.Metro__c}"/>
     <apex:column value="{!opty.Owner_Name__c}"/>
     <apex:column value="{!opty.StatusName__c}"/>
     <apex:column value="{!opty.Date_Entered_Into_Lead_Router__c}"/>
     <apex:column value="{!opty.Listing_Amount__c}"/>
     <apex:column value="{!opty.Listing_Agent__c}"/>
     <apex:column value="{!opty.Agent__c}"/>
     <apex:column value="{!opty.Referral_Fee__c}"/>
     <apex:column value="{!opty.Last_Activity_Subject__c}"/>


       </apex:pageblockTable>
    </apex:pageBlock>
 
    <apex:pageBlock title="Leads" id="lead">
    <apex:pageblockTable value="{!leadList }" var="lead">
     <apex:column headervalue="Name"><apex:outputLink value="/{!lead.ID}" target="_blank">{!lead.name}</apex:outputLink></apex:column>
     <apex:column value="{!lead.email}"/>
     <apex:column value="{!lead.Metro__c}"/>
     <apex:column value="{!lead.StatusName__c}"/>
     <apex:column value="{!lead.Date_Entered_Into_Lead_Router__c}"/>
     <apex:column value="{!lead.Listing_Amount__c}"/>
     <apex:column value="{!lead.Listing_MLS__c}"/>
     <apex:column value="{!lead.Listing_Agent__c}"/>
     <apex:column value="{!lead.Referral_Fee__c}"/>
     <apex:column value="{!lead.Last_Activity_Subject__c}"/>


 </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>
I want send an email from Organization-Wide Address but this accounts are should verify, the problem is that I couldn't verifying this type of address: testDisccounts@1-ys511gkea63b4vriwfq1nkw80jzyaa8t.<XXXX>.apex.sandbox.salesforce.com.
I should use this addres because when the customer reply the message, Saleforce should catch the text of the reply message and then execute an apex class.

Thank u.
Regards
Hi,

Im trying to create an Order and related order products in apex using lightning.
So basically i want to call a server method that creates order and order products when i click a checkout button.
I am able to do it in my lightning app. But when i put my component in a community(Napili template), and login as a community user , order and order products are not getting created when i call the same server method and my community page is getting refreshed instead. 
the server method is as follows,


@auraenabled
    public static string CheckOut(){
        
       
        String userID;
        userID = UserInfo.getUserId();
        list<user> u=[select id,Name from user where id=:userID];
        string nam= u[0].Name +'-Automated';
        list<Opportunity> Oppid=[select id from opportunity where name=:nam];
        system.debug('Oppid'+Oppid[0].id);
        string OID;
        OID=Oppid[0].id;
        
        list<OpportunityLineItem> OppListItems=[select OpportunityId,Quantity,UnitPrice,PriceBookEntryId,Product2Id,InMyCart__c,Wishlisted__c 
                                         from OpportunityLineItem where InMyCart__c=:true AND OpportunityId=:OID];
             
        if(OppListItems.size()>0){
            Order NewOrder = new Order(
               
                AccountId='0012800000ZKzhH',
                Status='Draft',
                EffectiveDate=System.today(),
               
                Pricebook2Id ='01s28000006q8A8',
                OpportunityId=Oppid[0].id
                
            );
            
            insert NewOrder;
             
            list <OrderItem> OrderitemList=new list<OrderItem>();
            
            For(integer i=0;i<OppListItems.size();i++){
                
                if(OppListItems[i].InMyCart__c==true){
                    OppListItems[i].InMyCart__c=false;
                    OrderItem OI=new OrderItem(
                        OrderId=NewOrder.Id,
                        Quantity=OppListItems[i].Quantity,
                        
                        PriceBookEntryId=OppListItems[i].PriceBookEntryId,
                        UnitPrice=OppListItems[i].UnitPrice
                        // Product2Id=OppLI[i].Product2Id
                        
                    );
                    OrderitemList.add(OI);
                }
            }
            system.debug('OrderitemList'+OrderitemList);
            insert OrderitemList;
            system.debug('OppLI'+OppListItems);
            update OppListItems;
            
            list<OpportunityLineItem> OppLIToDelete=[select id,name from OpportunityLineItem where InMyCart__c=:false AND WishListed__c=:false];
            delete OppLIToDelete;
            
            
        }   
        return OID;
    }



OppLIToDelete  is getting deleted . But order and order products are not getting created. Any help would be appreciated.

Thankyou
  • August 18, 2016
  • Like
  • 0
Hi,

Im trying to create an Order and related order products in apex using lightning.
So basically i want to call a server method that creates order and order products when i click a checkout button.
I am able to do it in my lightning app. But when i put my component in a community(Napili template), and login as a community user , order and order products are not getting created when i call the same server method and my community page is getting refreshed instead. 
the server method is as follows,


@auraenabled
    public static string CheckOut(){
        
       
        String userID;
        userID = UserInfo.getUserId();
        list<user> u=[select id,Name from user where id=:userID];
        string nam= u[0].Name +'-Automated';
        list<Opportunity> Oppid=[select id from opportunity where name=:nam];
        system.debug('Oppid'+Oppid[0].id);
        string OID;
        OID=Oppid[0].id;
        
        list<OpportunityLineItem> OppListItems=[select OpportunityId,Quantity,UnitPrice,PriceBookEntryId,Product2Id,InMyCart__c,Wishlisted__c 
                                         from OpportunityLineItem where InMyCart__c=:true AND OpportunityId=:OID];
             
        if(OppListItems.size()>0){
            Order NewOrder = new Order(
               
                AccountId='0012800000ZKzhH',
                Status='Draft',
                EffectiveDate=System.today(),
               
                Pricebook2Id ='01s28000006q8A8',
                OpportunityId=Oppid[0].id
                
            );
            
            insert NewOrder;
             
            list <OrderItem> OrderitemList=new list<OrderItem>();
            
            For(integer i=0;i<OppListItems.size();i++){
                
                if(OppListItems[i].InMyCart__c==true){
                    OppListItems[i].InMyCart__c=false;
                    OrderItem OI=new OrderItem(
                        OrderId=NewOrder.Id,
                        Quantity=OppListItems[i].Quantity,
                        
                        PriceBookEntryId=OppListItems[i].PriceBookEntryId,
                        UnitPrice=OppListItems[i].UnitPrice
                        // Product2Id=OppLI[i].Product2Id
                        
                    );
                    OrderitemList.add(OI);
                }
            }
            system.debug('OrderitemList'+OrderitemList);
            insert OrderitemList;
            system.debug('OppLI'+OppListItems);
            update OppListItems;
            
            list<OpportunityLineItem> OppLIToDelete=[select id,name from OpportunityLineItem where InMyCart__c=:false AND WishListed__c=:false];
            delete OppLIToDelete;
            
            
        }   
        return OID;
    }



OppLIToDelete  is getting deleted . But order and order products are not getting created. Any help would be appreciated.

Thankyou
 
  • August 18, 2016
  • Like
  • 0
Hello,

On the object case i have a field called "Case owner", this field is a look up.

this lookup can be "queue" or "user".

How can i know that if it is a "queue" or "user" in Apex ?

thanks for suggestions.
  • December 15, 2016
  • Like
  • 0
Hi,

I want to be able to populate a custom Case field with the data held in 'Assigned To' when you submt for approval.

So, when I press 'Submit for Approval' it is assigned to a User or a queue. I want a trigger that puts that info into a custom text field so that I can create a Cases list from it to see what is in a person 'waiting for approval' queue.

Is that possible?

Thanks

Matt
Can anybody tell me what is the relationship between Object, Field & Record terms? I understand all of those definitions but unable to understand the relationship between them.. If possible, please explain it any example..That would helpful for me relate these concepts in real time use cases.
Please help for for this..Its an urgent to me. 
Thank U.
Hello, 

I'm using the SOAP API using .NET.

I've stumbled upon a problem while trying to create an account with billing address information. The following exception message is available "Element {urn.enterprise.soap.sforce.com}city invalid at this location." If I remove the city field, it just switches the city field to another in the billing address structure, such as the PostalCode.

It seems like this is happening when performing an update (so I've done a SELECT QUERY before that). It looks like this: 

"SELECT AccountNumber, CurrencyIsoCode, BillingAddress FROM Account WHERE AccountNumber = {id}"

If I just remove the BillingAddress part from the query and as well as the BillingAddress structure from the account object, it seems to work. Although, of course I won't get the BillingAddress updated.

Thanks in advance!
Hi,

How can I create a LIFO Leads Assignment and establish a maximum of leads per person?

Thank you!
Hi @ all,
i tried to use the MIN function in the process builder with a auto number. But he tell me that he is expecting a number but received a text. Can someone help me?

Lisa
I am unable to login into my salesforce dataloader even after using correct username and password, the error I am getting while trying to login is "com.sforce.ws.connectorconfig.getNtmlDomain()Ljava/lang/String". Verified my login histroy and it's showing was able to login into dataloader successfully.
Any one have resolution?.
Thanks in Advance
Hello,

How to display currency in particular format($3,000.00) in Visualforce page and also in standard page layouts ?
 
  • November 10, 2016
  • Like
  • 0
Hi all,
I want  to send an email with PDF attachment when an submit button is clicked in my custom vfpage. Can any one help over here.

Regards,
Suneel.
Hello,

We are getting the error below when making the API call below. This seems to be happening because of the built-in dedupe logic in Salesforce.com (see screenshot). Can anyone tell me why the deduplicate logic is causing this API error? The lead/contact did not previously exist. 

API Error:
stdClass Object
(
    [errors] => stdClass Object
        (
            [fields] =>
            [message] => You are possibly creating a duplicate record. Please see Mike to verify lead status.
            [statusCode] => UNKNOWN_EXCEPTION
        )

    [id] =>
    [success] =>
)
 
Here is the call we are sending to the SFDC API:
 
$crmConn = new SforcePartnerClient ();
$this->crmConn->create ( $sObjects, 'Lead' );
 
Where the $sObjects we used was as following:
 
Array
(
    [0] => SObject Object
        (
            [type] => Lead
            [fields] => Array
                (
                    [Phone] => 207-588-1019
                    [FirstName] => Patti
                    [LastName] => Sutter
                    [Email] => psutter@mainetechnology.org
                    [Company] => Maine Technology Institute
                    [Country] => United States
                    [City] => Brunswick
                    [State] => Maine
                    [PostalCode] => 04011
                    [LeadSource] => Organic Search (SEO)
                    [Leadliaison__LLLastSearchEngine__c] => google
                    [Leadliaison__LLLeadLiaisonGrade__c] => C
                    [Leadliaison__LLLeadLiaisonScore__c] => 68
                    [OwnerId] => 00561000000vDYfAAM
                )
        )
 
)

Here are the duplicate lead settings in the instance:
Dedupe Settings
Hi Expert,

There r two objects "project member" and "resource" in which under "project member" object i have to update the field "hour rate" with "resource" object field "hour cost", when something is written in "hour cost" field, otherwise "hour rate" field not update and able to enter something and save it.

my code is- 

public class updateHourlyRate
{
 public static List<CloudbyzITPM__Team_Member__c> affectedProd= new
List<CloudbyzITPM__Team_Member__c>();
 public static List<CloudbyzITPM__Team_Member__c> affectedProd_final=
new List<CloudbyzITPM__Team_Member__c>();

 public static set<ID> afc2 = new set<ID>();
 public static void processAfterUpdateOrInsertHourlyCost(){
      affectedProd = (List<CloudbyzITPM__Team_Member__c>)Trigger.New;
     if(affectedProd.size()>0){
     for(CloudbyzITPM__Team_Member__c  affc : affectedProd){
      afc2.add(affc.CloudbyzITPM__Team_Member__c);
     }
     }
     CloudbyzITPM__Resource__c fn = [Select id,
CloudbyzITPM__Hourly_Cost__c from CloudbyzITPM__Resource__c where id
IN :afc2 limit 1];
     List<CloudbyzITPM__Team_Member__c> affectedProd1 = [Select
id,name,CloudbyzITPM__Hourly_Rate__c from CloudbyzITPM__Team_Member__c
where CloudbyzITPM__Resource__c = :fn.id];
    // Decimal i =0 ;
     if(affectedProd1.size()>0){
     for(CloudbyzITPM__Team_Member__c  affc : affectedProd1){

     affc.CloudbyzITPM__Hourly_Rate__c = fn.CloudbyzITPM__Hourly_Cost__c;
    affectedProd_final.add(affc);
    }
     }

     update affectedProd_final;
 }
}

trigger- trigger HourRate on CloudbyzITPM__Resource__c (before insert, before update, before delete, after insert, after update, after delete) 
{
if((Trigger.isInsert || Trigger.isUpdate) && Trigger.isAfter)   
{
updateHourlyRate.processAfterUpdateOrInsertHourlyCost();

}

when i change the field "hourly cost" , it gives an error.
"Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger HourRate caused an unexpected exception, contact your administrator: HourRate: execution of AfterUpdate caused by: System.TypeException: Invalid conversion from runtime type List to List: Class.updateHourlyRate.processAfterUpdateOrInsertHourlyCost: line 10, column 1"
Hi,

I am trying to write a trigger that will update a custom field that I created on the opportunity object called case status. It is a picklist field that I want to mirror the status picklist field on cases. I also created a lookup field on opportunities called related_case. The related_case field ties the two objects together. Right now my trigger works so that after i update the field on cases I then have to press edit and save on the opportunity page to get the field to update. What I would like to happen is have the opportunity page update on refresh after changing the case field. The trigger is currently built on the opportunity and I am thinking maybe it needs to be built on the case instead. 

I am attaching the code here and any help or advice is greatly appreciated.
 
trigger updateCaseStatus on Opportunity(After Update) {

      set<id> setid =new set<id>();
    
    for(Opportunity Opp: Trigger.new){
        if(Opp.Related_Case__c != null)
        {
        setid.add(Opp.Related_Case__c);
        }
     Case cas = [select id,Status from Case where Id in: setid];
     
              for(Opportunity Opps : trigger.new)
       {
              
          Opps.Case_Status__c= cas.Status;
          opps.Related_case__c = cas.id;

             }

   }
   }




Thanks,

Edward
 have a custom object called "SupportRequest" with a record type used by our sales and contracts team. I need to have a manual trigger (in this case a detail page button) that allows the creator of the record to update the record owner to a queue with a single click.

I am using this JS for the button:
{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")} try{ var CCA_QueueId; var CCA_QueueName = "CCA_Queue"; var queues = sforce.connection.query( "SELECT Id " + "FROM Group " + "WHERE Name = '" + CCA_QueueName + "'" ); if( queues.getArray( "records" ).length === 0 ) { alert( "Couldn't find a Queue with Name: " + CCA_QueueName + "!" ); } else { CCA_QueueId = queues.getArray( "records" )[0].Id; } if( CCA_QueueId !== undefined ) { var reqToUpdate = new sforce.SObject( "SupportRequest__c" ); reqToUpdate.Id = "{!SupportRequest__c.Id}"; reqToUpdate.OwnerId = CCA_QueueId; var result = sforce.connection.update( [reqToUpdate] ); if( result[0].getBoolean( "success" ) === true ) { location.reload(); } else { alert( "An Error has Occurred. Error: " + result[0].errors.message ); } } } catch( e ) { alert( "An Error has Occurred. Error: " + e.message ); }

This is code modified from other used and not my original work. I'm sure I'm missing somethign elementary but this falls outside of my skillset.  
Another note - the Queue API name is CCA_Queue but the Label is Contracts Queue if that makes any difference.

Thanks 
Hi,

I'm trying to create a sample report to use in the test class. I cannot use the SeeAllData=true because the test class is for a managed package and cannot assume that there is a sample report record available in the user's instance to use when they install it, so I really need to create a new report in the test class.

Is this even possible or a work around for this?
  • October 10, 2016
  • Like
  • 0