• Jason Beal
  • NEWBIE
  • 145 Points
  • Member since 2015

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
I have a huge formula compiled size 4,628 characters that I am trying to condense.
I think I can do it by stating the negative of a picklist value, but I'm not sure how to do it. Here is my formula:

CASE(text(Deployment_No__c),
"2",STI_Monthly_Cost__c + Cost_for_Discounted_Adults__c + Cost_of_Children__c + Addtl_Lodging_Cost_Total__c + Addtl_Cost_Incidentals__c + STI_Daily_Cost__c-Applied_Credit__c,
"3",STI_Monthly_Cost__c + Cost_for_Discounted_Adults__c + Cost_of_Children__c + Addtl_Lodging_Cost_Total__c + Addtl_Cost_Incidentals__c + STI_Daily_Cost__c-Applied_Credit__c,
0)

I want to rewrite the formula so that it will calculate if the picklist value is NOT "1". That way I can use each of them only once.

Looking forward to your brilliant answers! :)

Hi All I have a scenario here plese help me i am learner in salesforce please help me with this topic .... thanks in advance......

Create a Custom Formula Field Age in Contact (value needs to be calculated in Years Based on Date of Birth)
Then in account create 4 fields  Below 18, 18-30,31-59,60+ (Number Type)
Then create a Trigger and rollup the counts accordingly from Contact to Account.
For example
if there are 20 people under 18 then In Account Below 18 should show 20.
if there are 50 people under 18 -30 then In Account 18-30 should show 50…..
I am trying to override the Edit functionality on a related list on an object with a Visualforce page. My issue is that there is only 1 override to the standard Edit link for an Object for ALL users (internal or external) and it wants to launch the same Visualforce page regardless of if you are in the standard salesforce instance (internal user) or if you are in a Partner Community (external user).

This is a problem because links to internal visualforce URLs need to be "/apex/VisualforcePageName" where external pages need to just be "VisualforcePageName". For example the full URL would look like http://na2.salesforce.com/apex/VisualforcePageName for internal and for the community site it would be http://mydomain.force.com/sitename/VisualforcePageName .

Specifially my code is using a Javascript to open a new window with a relative link:
<script>
        window.onload = newPage();
        var popUp;
        function newPage()
        {
            if ({!ContinueForm} == true)
            {
                popUp = window.open('/apex/VisualforcePageName?cid={!ConfigId}');
                if (popUp == null || typeof(popUp)=='undefined') 
                {   
                    alert('Please disable your pop-up blocker or allow pop-ups from "{!URLInfo}" and click link again.'); 
                }
            }
            redirectPage();
        }
</script>

If there is another way to open a link to a visualforce page in a New Window (for both Internal and Community) I am ok going that route too instead of trying to modify the URL.

Thanks!
Hi Developer Forums,
I need to take a String of the format "July 9, 2015" and turn it into a Date object.

Apex doesn't seem to let me instantiate DateFormat / SimpleDateFormat objects, so I can't write my own format to use with a ".parse()" method.  The "9" and the "2015" are close enough to integers, so I can do some annoying string transformation to get my input to "Date.parse()" into the type of string Apex expects, but I really don't want to write 12 lines of code to turn spelled-out months into numbers.

Ordinarily in Java, I'd just try this:
DateFormat myFormat = new SimpleDateFormat('MMMM d, yyyy', Locale.ENGLISH);
Date myDate = myFormat.parse(myQuirkyDateString);
(via http://stackoverflow.com/a/11493647)

But that doesn't compile in Apex.

What can I do to turn this type of string into a Date?

Thanks!
-K.
  • July 09, 2015
  • Like
  • 0
I have a huge formula compiled size 4,628 characters that I am trying to condense.
I think I can do it by stating the negative of a picklist value, but I'm not sure how to do it. Here is my formula:

CASE(text(Deployment_No__c),
"2",STI_Monthly_Cost__c + Cost_for_Discounted_Adults__c + Cost_of_Children__c + Addtl_Lodging_Cost_Total__c + Addtl_Cost_Incidentals__c + STI_Daily_Cost__c-Applied_Credit__c,
"3",STI_Monthly_Cost__c + Cost_for_Discounted_Adults__c + Cost_of_Children__c + Addtl_Lodging_Cost_Total__c + Addtl_Cost_Incidentals__c + STI_Daily_Cost__c-Applied_Credit__c,
0)

I want to rewrite the formula so that it will calculate if the picklist value is NOT "1". That way I can use each of them only once.

Looking forward to your brilliant answers! :)
I am trying to update parent stage(Opportunity: StageName) with child stage (Line_item__c : Stage__C) and get the error:

Compile Error: Loop with query must provide a statement at line 4 column 12


trigger ControlOpportunityStage on Line_Item__c (after update) {
       List<Opportunity> parentlist = new List<Opportunity>();
       List<Opportunity> opportunityId = new list<Opportunity>();
           for(Line_item__c lirecord : [SELECT Opportunity__r.id, Opportunity__r.StageName from Line_item__c
               where Line_item__c.Opportunity__c <> null]);{
               
               
       
           
        for(Opportunity opt : parentlist)
            if(Opportunity.StageName != Line_item__c.Stage__c){
                Opportunity.StageName = Line_item__c.Stage__c;
                optId.add(opt);
            
      }
     }
         if(opportunityId != null & opportunityId.Size()>0)
            upsert opportunityId;
}
hi, 
 Actually i dont know what to do here to achive my logic.

my required condition is ,  there is a course in COURSE__C object, we need 2 values to perfoam reqiored operation,  

1) Total_no_of_seats__C  (i am giving it as 60)   no problem at here.
2)Total_students_booked_seats_upto_now( i need this) 

because i need to write some validation rule at student_registration_for_new couse....  please help

validation rule at student__C object is

User-added image
 
Hi,

Is there anyway to include anyfield cahnge in an email template. In Cases when a user updates any field (not a specific field) an email alert should be sent wherein the email template should specify which field has changed. There are many fields in cases, so the email template should specify only the one which has been changed or edited.

Please let me know how can we do this.
My custom app would like to know the public IP address of the client making a custom SOAP web service call.

I see that the RestRequest (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_restrequest.htm#apex_methods_system_restrequest) class exposes both a remoteAddress and headers property.

I'm looking for something similar in a custom SOAP web service. Is there an equivalent?

So if my API wanted to send a different response if called from a well-known IP (for example, Google's DNS), I would expect the code to look something like this:
webservice static string MyCustomApi(MyRequest request)
{
    return (SoapContext.Request.remoteAddress == "8.8.8.8")
        ? "Hello Google DNS"
        : "Hello, someone other than Google";
}

Is that possible? I can't find any documentation that says it is possible from SOAP, only from REST, and that seems rather unfortunate.
I have a twe date/time fields: Date1__c and Date2__c.

I need to calculate working days between two date/time field excluding weekends with fraction value.

Eg., Date1__c = '2015 - 07 - 08 13:00'
        Date2__c = '2015 - 07 - 10 15:00'
        difference: 2.08

Hi All I have a scenario here plese help me i am learner in salesforce please help me with this topic .... thanks in advance......

Create a Custom Formula Field Age in Contact (value needs to be calculated in Years Based on Date of Birth)
Then in account create 4 fields  Below 18, 18-30,31-59,60+ (Number Type)
Then create a Trigger and rollup the counts accordingly from Contact to Account.
For example
if there are 20 people under 18 then In Account Below 18 should show 20.
if there are 50 people under 18 -30 then In Account 18-30 should show 50…..
I am trying to override the Edit functionality on a related list on an object with a Visualforce page. My issue is that there is only 1 override to the standard Edit link for an Object for ALL users (internal or external) and it wants to launch the same Visualforce page regardless of if you are in the standard salesforce instance (internal user) or if you are in a Partner Community (external user).

This is a problem because links to internal visualforce URLs need to be "/apex/VisualforcePageName" where external pages need to just be "VisualforcePageName". For example the full URL would look like http://na2.salesforce.com/apex/VisualforcePageName for internal and for the community site it would be http://mydomain.force.com/sitename/VisualforcePageName .

Specifially my code is using a Javascript to open a new window with a relative link:
<script>
        window.onload = newPage();
        var popUp;
        function newPage()
        {
            if ({!ContinueForm} == true)
            {
                popUp = window.open('/apex/VisualforcePageName?cid={!ConfigId}');
                if (popUp == null || typeof(popUp)=='undefined') 
                {   
                    alert('Please disable your pop-up blocker or allow pop-ups from "{!URLInfo}" and click link again.'); 
                }
            }
            redirectPage();
        }
</script>

If there is another way to open a link to a visualforce page in a New Window (for both Internal and Community) I am ok going that route too instead of trying to modify the URL.

Thanks!
User-added image
How do I add Page# of Total Page# in VF custom page? I only able to get Page#, I could not get the other part ( Of Total Page). Any Idea. Thanks 
 
<apex:panelGrid columns="9">
                <div id="panel">
                    <apex:commandLink action="{!first}">First</apex:commandlink>
                    <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
                    <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
                    <apex:commandLink action="{!last}">Last</apex:commandlink> 
                    <apex:outputText value="Page #{!pageNumber}"/>
                    <b>Record :</b>
                    <apex:outputText rendered="{!(setpb.pageNumber * setpb.pageSize) < setpb.ResultSize}" value="{!setpb.pageNumber * setpb.pageSize} OF {!setpb.ResultSize}"></apex:outputText>
                    <apex:outputText rendered="{!(setpb.pageNumber * setpb.pageSize) >= setpb.ResultSize}" value="{!setpb.ResultSize} OF {!setpb.ResultSize}"></apex:outputText>
                  
                </div>
            </apex:panelGrid>
Extension 
 
public class DispatcherContactNewController {

    public DispatcherContactNewController(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    private integer offset; // Keeps track of the offset     
    private integer pageSize;   // Page size or number of rows           
    public integer totalRecords;  // Total number of records  
    
    public ApexPages.StandardSetController setpb{
        get{
            if(setpb == null){
                setpb = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [SELECT Id, Name, RecordTypeId, Createddate FROM Product_Brief__c ORDER BY Createddate DESC ]));
                         setpb.setPageSize(10);
                         }
                         return setpb;
           } 
        set;
        
    }
    
    public List<Product_Brief__c>getpbs(){
        return (List<Product_Brief__c>)setpb.getrecords();
    }
    
    public Boolean hasNext {
        get {
            return setpb.getHasNext();
            }
        set;
    }
    
    public Boolean hasPrevious {
        get {
            return setpb.getHasPrevious();
            }
        set;
    }
    
    public Integer pageNumber {
        get {
            return setpb.getPageNumber();
            }
        set;
    }
    
    public void first() {
         setpb.first();
    }
     
    public void last() {
         setpb.last();
    }

    // returns the previous page of records
    public void previous() {
        setpb.previous();
    }

    // returns the next page of records
    public void next() {
        setpb.next();
    }
}




 
Hi Developer Forums,
I need to take a String of the format "July 9, 2015" and turn it into a Date object.

Apex doesn't seem to let me instantiate DateFormat / SimpleDateFormat objects, so I can't write my own format to use with a ".parse()" method.  The "9" and the "2015" are close enough to integers, so I can do some annoying string transformation to get my input to "Date.parse()" into the type of string Apex expects, but I really don't want to write 12 lines of code to turn spelled-out months into numbers.

Ordinarily in Java, I'd just try this:
DateFormat myFormat = new SimpleDateFormat('MMMM d, yyyy', Locale.ENGLISH);
Date myDate = myFormat.parse(myQuirkyDateString);
(via http://stackoverflow.com/a/11493647)

But that doesn't compile in Apex.

What can I do to turn this type of string into a Date?

Thanks!
-K.
  • July 09, 2015
  • Like
  • 0