• ~Onkar
  • NEWBIE
  • 398 Points
  • Member since 2007

  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 80
    Replies
I'm having a problem with getting a formula field to calculate the correct percentage. I have 3 fields    Cost (currency field) Number of Months(Number Field) Retainer(Percent Field)

I'm trying to create a formula that shows the results of
Cost__c * Number_Of_Months__c - Retainer__c

But when i view the Total__c field, My formula is only reducing the amount by the number I enter into the retainer field.

So I enter 1,000 into the cost field and 5 in the number of months  field and 5 percent in the retainer field  my return value is $4,999.95 not 4,750. Can any one help me with this formula? 
  • August 05, 2019
  • Like
  • 0
Hello,
I need to export the State & Country picklist values which I think are in the Settings folder in the workbench but I need an xml file to do so

Looking for the format of the xml file needed
There is a duplicate rule on Account object enabled in my org. I have a customize lead convert classic page, in which if I select Create New account option then on click of convert button, it should display the error message of the duplicate rule. I added the below code to be displayed in error messge.
Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);
        
        // if the lead converting was a success then create a task
        if (!leadConvertResult.success)
        {
           PrintErrors(leadConvertResult.errors);
            
            return null;
         }

    //this method will take database errors and print them to teh PageMessages 
    public void PrintErrors(Database.Error[] errors)
    {
        for(Database.Error error : errors)
        {
            if(error instanceof Database.DuplicateError)
            {
               Database.DuplicateError duplicateError = (Database.DuplicateError)error;
               Datacloud.DuplicateResult duplicateResult = duplicateError.getDuplicateResult();
			// Display duplicate error message as defined in the duplicate rule
               ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.Severity.ERROR, 'You are creating a duplicate record. We recommend you use an existing record instead.');
               System.debug('The error message'+errorMessage);
                ApexPages.addMessage(errorMessage); 
            }
        }
    }
The above code doesn't provide the simple error message as mentioned in the code. However I recieve a the below error. What is it that I am doing wrong here ?
Hi
I am trying to understand trigger basics, so I have an custom field HelloWorld in acocunt object and when I create a new record I am updating the custom field with some value and the code is working
My requirement is to update the custom field in the old account records also.
How to access old record records?
Pls let me know.
public class HelloWorld
{
   public void Display(List<Account> acc)
    {
       for(Account val:acc)
       {
           if (val.Hello__c == null)
                 val.Hello__c='World';
       }
    }
} 

trigger trgupd_hello on Account (before Insert,before update,before delete,after insert,after update,after delete,after undelete)
{
      if (trigger.isBefore) 
      {
           if (trigger.isInsert)
           {
               HelloWorld obj_hello=new HelloWorld();
               obj_hello.Display(trigger.new);  
            }
     } 
}

Thanks
Pooja Biswas
Hi folks
    Can anyone tell me how to add custom button to the contact related list in Account Page layout

Thanks in advance,
Karthick
Hi 
I was wondering if anyone can help me with test class for the trigger below

trigger createNewRecord on Audits__c (after update){
   list<Audits__c> newList = new list<Audits__c>();
  
   for (Audits__c p:Trigger.new){
   
     if ((p.Closed_Date__c!=trigger.oldMap.get(p.ID).Closed_Date__c)&(p.Closed_Date__c==Date.today())){
       
        Audits__c au = new Audits__c(Name=p.name,Frequency__c=p.Frequency__c,Date__c=p.Closed_Date__c,Account__c=p.Account__c,Status__c='Opened');
        newList.add(au);
     }
   }
   if(newList.size()>0)
   {
      insert newList;
   }     
}

Thanks
I want to update user's public group when account changed or user profile changed.How can I dynamatic update it through trigger?
I am trying to pass the  value captured from text box as query string to another visualforce page on button click.
Here is my code:

 VF Page:

<apex:page id="pg" controller="OnLoadController">
<apex:form >
<script type="text/javascript">
      function doSearch() {
        contactSearch(document.getElementById("searchBox").value);
        alert(document.getElementById("searchBox").value);

      }
</script>
<apex:actionFunction action="{!redirect}" name="contactSearch">
    <apex:param name="searchBox" value=""/>
</apex:actionFunction>
<apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="btn1" onclick="doSearch(); return false;"/>
        </apex:pageBlockButtons>
        <input type="text" id="searchBox" />
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller:
public class OnLoadController {

    public String searchName {get; set;}

    public PageReference redirect()
    {
        searchName = Apexpages.currentPage().getParameters().get('searchBox');
        PageReference searchResult= new PageReference('/apex/VF_SearchDetails?searchCriteria='+ searchName);
        searchResult.setRedirect(true);
        return searchResult;      
       
    }

}

But it is redirecting to the page with null query string value.
Please help.
The invoices.get( ... ) in the last line returns null because the invoices keySet contains keys which are not Opportunity__c.Id's like I expected. I am doing something like this in the following execute anonymous code:

Id key = '006G000000TZ2f9IAD';
Map<Id, Invoice1__c> invoices = new Map<Id, Invoice1__c> ([SELECT Opportunity__c
                                                                , Name
                                                            FROM Invoice1__c
                                                            WHERE Opportunity__c = :key]);

system.debug('Created Map. Number of Invoice names mapped=' + invoices.size());
system.debug('Invoices.Get=' + invoices.get(key));

I would like to be able to pull the Invoice1__c.Name from the Map something like:

String invoiceName = invoices.get(newTicket.sbx_Opportunity__c).Name;

1. How do I properly populate a Map of <OpportunityID, Invoice1__c.Name>. Like this <006G000000TZ2f9IAD, 'Inv-0561'>

2.  What are the Id's that I currently see in the invoices variable keySet?
How can we restrict a user to see a record?

Hi All

 I keep getting the error message;

 Compile Error: Field is not writeable: LeadShare.LeadId at line 14 column 57

 

if(PartnerUsermap.ContainsKey(ld.createdById)){
                    partnershare = new LeadShare(LeadId=ld.id,UserOrGroupId=ld.createdById,leadaccesslevel='read');
                    leadshares.add(partnershare);
                  }

 

How to overcome this?Please suggest

 

Cheers

Hi,

 

I have got error

 [{"message":"HTTPS Required","errorCode":"UNSUPPORTED_CLIENT"}]

 

when i call service hosted in site from apex page .

 my code is below

 

my source code:

 

<apex:page controller="getservice2">
<apex:form >
<apex:commandButton action="{!getResult}" value="Submit"> </apex:commandButton>
<br/><br/> {!myresponse}
</apex:form>
</apex:page>

 

public class getservice2
{
public String myresponse{get;set;}
public Pagereference getResult()
{
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('GET');
String url = 'http://sarveswararao-developer-edition.ap1.force.com/services/apexrest/GetService ';
req.setEndpoint(url);
req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
HTTPResponse resp = http.send(req);
myresponse=resp.getBody();
return null; }
}

 

my target code in site

 

@RestResource(urlMapping='/GetService/*')  
global with sharing class getservice1
{      
     @HttpGet     
     global static String postRestMethod()     
     {          
          return 'Hi, You have invoked getservice1 created using Apex Rest and exposed using REST API';        
     }
}

 

please suggest me 

 

Thanks ,

Sarvesh.

 

 

Hello,

 

Is there any way that we could show some custom fields on an Opportunity ONLY to a selected set of users? All the users in that profile should not see the field but for this set.

 

Thanks for the help.. !!!

 

Radram

 

  • September 24, 2012
  • Like
  • 0
I would like to redirect to a Visualforce page I've created when a user saves an Opportunity, and the Opportunity is closed/won. I've written a trigger to test the logic and the new VIsualforce page, but I'm stumped on how to accomplish the redirect because apparently according to this thread: http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=3321 you can't redirect from a trigger.

Does anyone have any ideas on how to accomplish this?

Thanks in advance...
If I am writing trigger on any object for some Calculation before inserting data in object.
I need some help that can we avoid validation rule on object and put this validation in trigger?
What is the best practice write validation in trigger or write validation rule separate ?.

Message Edited by Onki3 on 12-30-2008 10:24 PM
  • December 30, 2009
  • Like
  • 0
I am trying to craete custom object and custom filed on this custom object. but it gives error.

No operation available for request {http://soap.sforce.com/2006/04/metadata}create

can anybody help me. i am using asp.net with c#.



Hi
I am trying to add force.com plugin with eclipse but its gives error.

My system is under firewall and i specify all proxy setting in eclipse.

!SUBENTRY 1 org.eclipse.update.core 4 0 2008-06-04 12:44:42.273 !MESSAGE The File "C:\DOCUME~1\OK76384\Local Settings\Temp\eclipse\.update\1212555238231\1212555238389\eclipse10130.tmp" is not a valid JAR file. [error in opening zip file] !STACK 0 java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(Unknown Source) at java.util.jar.JarFile.<init>(Unknown Source) at java.util.jar.JarFile.<init>(Unknown Source) at org.eclipse.update.internal.verifier.CertVerifier.init(CertVerifier.java:77) at org.eclipse.update.internal.verifier.CertVerifier.verify(CertVerifier.java:129) at org.eclipse.update.core.Feature.verifyReferences(Feature.java:967) at org.eclipse.update.core.Feature.install(Feature.java:377) at org.eclipse.update.internal.core.SiteFile.install(SiteFile.java:96) at org.eclipse.update.internal.core.ConfiguredSite.install(ConfiguredSite.java:155) at org.eclipse.update.internal.core.ConfiguredSite.install(ConfiguredSite.java:119) at org.eclipse.update.internal.operations.InstallOperation.execute(InstallOperation.java:92) at org.eclipse.update.internal.operations.BatchInstallOperation.execute(BatchInstallOperation.java:84) at org.eclipse.update.internal.ui.wizards.InstallWizard2.install(InstallWizard2.java:373) at org.eclipse.update.internal.ui.wizards.InstallWizard2.access$1(InstallWizard2.java:370) at org.eclipse.update.internal.ui.wizards.InstallWizard2$1.run(InstallWizard2.java:483) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Hi,

How can we aceess or use "ASP.net WSDL" in Apex class.
when i am trying to use this its give the following error
"Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported"

Please help


  • February 20, 2008
  • Like
  • 0
I'm having a problem with getting a formula field to calculate the correct percentage. I have 3 fields    Cost (currency field) Number of Months(Number Field) Retainer(Percent Field)

I'm trying to create a formula that shows the results of
Cost__c * Number_Of_Months__c - Retainer__c

But when i view the Total__c field, My formula is only reducing the amount by the number I enter into the retainer field.

So I enter 1,000 into the cost field and 5 in the number of months  field and 5 percent in the retainer field  my return value is $4,999.95 not 4,750. Can any one help me with this formula? 
  • August 05, 2019
  • Like
  • 0
Hello,
I need to export the State & Country picklist values which I think are in the Settings folder in the workbench but I need an xml file to do so

Looking for the format of the xml file needed
Hello.I am new using SFDC and i have a problem now.

I want to select some data that was created 14 days ago. so i wrote soql like this:
Select Id, CreatedDate FROM ***** WHERE CreatedDate < Last_N_DAYs:14 order by CreatedDate DESC
for example today is 19th so i want to get the date before 5th, but the latest date i get is 2016-08-03T23:34:01.000+0000
FYI i am in UTC 9 time zone. but it is still not right considering the time zone thing.  

I appriciate if someone can tell me what is wrong with it. thanks.
There is a duplicate rule on Account object enabled in my org. I have a customize lead convert classic page, in which if I select Create New account option then on click of convert button, it should display the error message of the duplicate rule. I added the below code to be displayed in error messge.
Database.LeadConvertResult leadConvertResult = Database.convertLead(leadConvert);
        
        // if the lead converting was a success then create a task
        if (!leadConvertResult.success)
        {
           PrintErrors(leadConvertResult.errors);
            
            return null;
         }

    //this method will take database errors and print them to teh PageMessages 
    public void PrintErrors(Database.Error[] errors)
    {
        for(Database.Error error : errors)
        {
            if(error instanceof Database.DuplicateError)
            {
               Database.DuplicateError duplicateError = (Database.DuplicateError)error;
               Datacloud.DuplicateResult duplicateResult = duplicateError.getDuplicateResult();
			// Display duplicate error message as defined in the duplicate rule
               ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.Severity.ERROR, 'You are creating a duplicate record. We recommend you use an existing record instead.');
               System.debug('The error message'+errorMessage);
                ApexPages.addMessage(errorMessage); 
            }
        }
    }
The above code doesn't provide the simple error message as mentioned in the code. However I recieve a the below error. What is it that I am doing wrong here ?
Hi
I am trying to understand trigger basics, so I have an custom field HelloWorld in acocunt object and when I create a new record I am updating the custom field with some value and the code is working
My requirement is to update the custom field in the old account records also.
How to access old record records?
Pls let me know.
public class HelloWorld
{
   public void Display(List<Account> acc)
    {
       for(Account val:acc)
       {
           if (val.Hello__c == null)
                 val.Hello__c='World';
       }
    }
} 

trigger trgupd_hello on Account (before Insert,before update,before delete,after insert,after update,after delete,after undelete)
{
      if (trigger.isBefore) 
      {
           if (trigger.isInsert)
           {
               HelloWorld obj_hello=new HelloWorld();
               obj_hello.Display(trigger.new);  
            }
     } 
}

Thanks
Pooja Biswas

Is there a way APEX, Visualforce, Admin settings or anything that will disable a user to create their own column search?

So when I search for something and click on show more, is there are a way to disable the customize section for other users such as My columns and Columns and buttons for All users?

User-added image

Only reason because I dont want the users be able to access some data.

Thanks in advance

  • April 13, 2016
  • Like
  • 0
I need to display products in Order object. We are using 'Order Products (Pricebook)' standard object which is in lookup with 'Orders'. But i am unable to find api name of 'Order Products' standard object to query them products selected from pricebook.

I need to show both "order details" and "products in order (Order Products)" details.

My contoller code. Working for only retriving orders. Not working for quering order products (Pricebook)
 
public with sharing class OrdersController {

    public List<Order> orderList {get;set;}
    
    public OrdersController(){
        orderList = new List<Order>();
    }
    
    public List<Order> getOrders(){
        return [SELECT OrderNumber, TotalAmount, Status (Select Product2Id, Product2.Name From PricebookEntry__r Where Product2Id =: productdet) FROM Order WHERE OwnerID=: UserInfo.getUserId()];
    }
 }
My VF code:
 
<apex:page controller="OrdersController" showHeader="false">

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
    
jQuery.noConflict();
    
    jQuery(document).ready(function($) {
        
        $("#pnl_details").hide();
 
        $('#viewDetails').click(function () {
            if ($("#pnl_details").is(":hidden")) {
                $("#pnl_details").slideDown("slow");
                $("#viewDetails").html("Show Less Details");
                 return false;
            } else {
                $("#pnl_details").hide("slow");
                $("#viewDetails").html("Show More Details");
             return false;
            }
            });         
    });
</script>

  <apex:pageBlock >
  <!-- <apex:repeat value="{!Orders}" var="owd">
            ['{!owd.OrderNumber}','{!owd.TotalAmount}','{!owd.Status}']
</apex:repeat> -->
  <apex:pageBlockSection title="Orders" id="pnl_details" columns="1">
        <apex:pageBlockTable value="{!orders}" var="o">
      
            <!-- <apex:column headerValue="Order Number">
                <apex:commandLink action="{!URLFOR($Action.Order.View, o.id)}" value="{!o.OrderNumber}"/>
            </apex:column> -->
            <apex:column value="{!o.OrderNumber}"/>
            <apex:column value="{!o.TotalAmount}" />
            <apex:column value="{!o.Status}" />
            
      </apex:pageBlockTable>
  </apex:pageBlockSection>
<apex:pageBlockSection columns="1">
    <apex:relatedList list="Pricebook2 " />
</apex:pageBlockSection>
  </apex:pageBlock>

</apex:page>



help me in this.
 
  • April 13, 2016
  • Like
  • 0
I have a bunch of new Contacts without an Account name field.  However, I have a custom field on the Contact Level called email Domain; how can I create a WF or trigger, where if the custom field Email Domain matches then the Account Name should be the same as well.

For Example
I have: 

Name:Bruce Wayne                                       
Account: Wayne Enterprise
Email Domain: abcinc.com

IF
Name: Clark Kent
Account: (blank)
Email Domain: abcinc.com

Then for Contact Clark Kent then Account = Wayne Enterprise.

 
Hiii,
Can any one please help me out in generating report on task object, I am able to display only single object records but i need to display as shown below:.. 
User-added image
Thanks in Advance.
  • April 12, 2016
  • Like
  • 2
I need to create a VF Page for Account for creating, viewing and editing records. What is the best approach to handle the fields for opening them for edit and view only mode? Can we use the same VF page to handle all the scenarios? How to code controller logic to handle multiple scnearios(save, edit and view)?
public with sharing class SendNamerFinacialSdlGroup{
i have the method where i will check the lead (lead records related to group members) owners and status is not changed with in 24 hoursthen  i will update the checkbox__x to true.

Currently i have written the code until fetching the leads related to particulr public group of test_Team.Please suggest me how to check the existed old status with new lead status in apex class to process furthur.
 public static void updateNamercheckbox(List<Lead> allleadlist){
       set<id> useridset=new set<id>();
       set<id> leadid=new set<id>();
       
       for(Lead led:allleadlist){
       leadid.add(led.ownerId);
       }
        List<Group> pbgrpid = [select id from Group where type='Regular' AND DeveloperName='test_Team'];
        List<GroupMember> userids = [select UserOrGroupId,GroupId  from GroupMember where GroupId IN:pbgrpid];
          for(GroupMember gmid:userids){
            useridset.add(gmid.UserOrGroupId);
            }
          system.debug('useridset' +leadid);
    
}
}
Hi all,

I was wondering if its possible for a trigger to automatically create an opportunity product when an opportunity is closed won.

I have an Object related to the opportunity that has fields called Product_Name__c and Total_Price__c.

I would like the trigger to populate these fields into the corresponding fields on the Opportunity Products object.

Thanks
Hi All,

I'm running one time update using Execute Anonymous and getting error "Salesforce SOQL Error Too many SOQL 001" for the following code, I tried few options to change the code but couldn't run the update, anyone can help with this code please: (Opportuntiy is master for custom object Sales Team, 1 : M)

List <Opportunity> OpptySalesRep = [Select Id,Sales_Rep__c From Opportunity Where  Sales_Rep__c !=null and (CreatedDate > 2014-11-01T00:00:00Z and CreatedDate <= 2014-11-30T00:00:00Z)];    

    set<Id> opportunityIdSet = new set<Id>();
        for (Opportunity Oppty : OpptySalesRep) {
          
            list<Sales_Team__c> newGSTmember = new list<Sales_Team__c>(); 
           
            opportunityIdSet.add(Oppty.Id); //Needed for following SOQL for GST       

           //Query to get all Sales team memeber for the opportunity                    
           List <Sales_Team__c> gst = [Select Sales_Team_Member__c,Primary__c,Producer__c,Opportunity__c,Id
                                             From Sales_Team__c
                                             Where Opportunity__c  IN: opportunityIdSet and  Producer__c = null and Opportunity__c <> null];
                                        
                                             system.debug('Number of Sales Team Member# ' + gst.size());
            
            //Reset  opportunityIdSet for avoid duplicate iteration 
             opportunityIdSet.remove(Oppty.Id);
                           
            boolean IsnewSalesRep = true;  //to check if Sales Rep already exists in GST            
              
           // Loop through the list and update GST record that matches to Sales Rep
           for (Sales_Team__c OpptyGST : gst){
              system.debug('GST Memebr# : ' + OpptyGST.Sales_Team_Member__c);                        
              
              //Update Sales Rep to Primary
              if (OpptyGST.Sales_Team_Member__c == Oppty.Sales_Rep__c){
                  system.debug('INSIDE If');
                  OpptyGST.Primary__c = true;
                    IsnewSalesRep = false;
                }
              // Update Sales reps to non-primary
                else if (OpptyGST.Sales_Team_Member__c != Oppty.Sales_Rep__c && OpptyGST.Primary__c == true){
                  system.debug('INSIDE else If');
                  OpptyGST.Primary__c = false;
              }
                            
              }
            
            //Add Sales Rep to GST          
             if (IsnewSalesRep == true)
             {
             Sales_Team__c newGST = new Sales_Team__c (); //instantiate the GST object to put values
                          
            newGST.Sales_Team_Member__c = Oppty.Sales_Rep__c;
             newGST.Primary__c = true;
             newGST.Opportunity__c = Oppty.Id;
             newGSTmember.add(newGST);
             insert newGSTmember;
             
              }
           
              update gst;  
                         
           }