• gurumike
  • NEWBIE
  • 115 Points
  • Member since 2009

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

I'm trying to calculate the number of days based on total hours in a month for an 8 hour workday.

 

For example, if there are 40 hours specificed for a month: 40 / 8 = 5 days

 

The problem is when I'm calculating hours that have a remainder.

 

For example, if there are 12 hours for a month: 12 / 8 = 1.5 days

 

Or, if there are 25 hours for a month: 25 / 8 = 3.125 days

 

Or, if there are 4 hours for a month: 4 / 8 = 0.5 days

 

Anytime there is a remainder, the calculation should round to the next highest integer value.

 

1.5 should round to 2

3.125 should round to 4

0.5 should round to 1

etc.

 

Here is what I was trying:

 

 

Integer recurrenceInterval = math.round((s.Hours__c / 8)-1);                

Integer hours = math.round(s.Hours__c);                

Integer remainder = math.mod(hours,8);                

if (remainder > 0) {                    
recurrenceInterval = recurrenceInterval + 1;                
}

 

My code isn't adding the necessary day in some instances.

 

Thanks for any help.

 

Hello,

I am trying to develop a page that shows the records of a custom object in a panelGrid according to a filter, where the user specifies values for the object's fields. I want to write a controller extensions that fetches the records from the Database using SOQL, but I need to get the values from the page, after the user types it. It probably will be something like [select field1, field2 from customobject__c where field1 = :ApexPages.currentPage().... (i don't know the rest)]

Thanks

Hello,

 

I am trying to test for a valid date format (mm/dd/ccyy) at the beginning of a text field with no luck.  I have the following formula- NOT(REGEX(Description , "^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d"))

and if I only put 01/01/2009 in the text field it works but if I put anything after the date it fails.  For example, 01/01/2009 - This is a test to validate the regular expression -- that does not work!

 

I thought the ^ checked only the beginning for a match?  Any help would be appreciated.  We have a free form text box and the business requires that every time an entry is made it must begin with the date that they enter the text.  I know my approach above is only validating for a format; therefore, if you can help me with that it would be a start.  However, if you could even help me confirm that the beginning of the text field has the current date that would be even better.  I do not want to auto populate it because they may have already entered it and that would create a dup date.

Hi there,
 
how is one supposed to create an "OpportunityPartner" object using the API? According to the Apex Explorer this object is only query-able and retrieve-able, so basically a readonly construction.
 
So, is creating/updating a new OpportunityPlan plain impossible is there just a trick that I'm unaware of? 
 
Cheers,
Harry
  • October 02, 2008
  • Like
  • 0

I've recently deployed a new VF page and controller which are exhibiting very odd behavior.  The page and controller make use of other components and classes, which all work in other contexts (hooray for code re-use).  However, when my users load this new page, they get an "Insufficient privileges" error.  In an attempt to figure out what was missing, I went through every single security setting in the profiles, and I have determined that the "View all data" admin privilege is required for my new page and controller to not give the security error.  I determined this by granting all permissions to every object in my whole org - CRUD, view all, and modify all - to the affected users' profile.  That didn't work.  Adding the "View all data" permission does work, even after taking away all the permissions I'd expect not to need.  So, in essence, my page & controller really do need "View all data" for some inexplicable reason.

 

Having looked through all the code, I'm only querying standard & custom objects - I can't imagine why "view all data" is required, especially since most of the code is shared and works properly in other contexts.  The only DML done during construction is select statements.  I added a try/catch in the page controller's constructor around all the code there, in an attempt to catch the security exception and display it, but that didn't change the error at all.  I got my user to give my login permission, but in order to view the system log (and thus figure out what's going on), I need to have the "view all data" permission... so when logged in as the user, I can't both reproduce the problem and debug it.  Argh!

 

As a short-term work-around I've changed to using "without sharing" on all of the related classes.  That seems to have worked, but isn't viable in the long-term.  Has anyone else run into this before?  Is there anything in the schema that could possibly require "view all data" to query?

 

I'm hoping one of the salesforce developers will read this - if so, my case # is 04306977.

 

I have handed off responsibility for my org's Apex code development to another person, but I'm still receiving "Developer script execution" error emails on occasion.  How do I get these emails to go to a different user?

I have created two custom objects in a master-detail relationship for managing a company process.  The master (parent) object has some fields including checkboxes for a checklist.  The detail (child) object has a lookup field for a Contact record, and a multi-picklist for the contact's "Role."

 

I want to alert the contacts in the child objects that have certain roles whenever a particular checkbox is checked on the master.

 

The way I've tried going about this is to first create a trigger on the master object that simply updates all of its child objects whenever it is edited.  This is a hacky workaround for getting workflows to run on child objects whenever the master object is edited.  Here's the trigger:

 

trigger touchFulfillmentContacts on Fulfillment__c (after update) {
    Fulfillment_Contact__c[] related = [ select Id, Fulfillment__c, Role__c from Fulfillment_Contact__c
                                         where Fulfillment__c in :Trigger.newMap.keySet() ];
    update related;
}

 

Secondly, I created a workflow on the child object that runs as follows:

 

Evaluation Criteria: When a record is created, or when a record is edited and did not previously meet the rule criteria

 

Rule Criteria (Formula):

 

AND(NOT(ISNULL(Fulfillment__c)), Fulfillment__r.Order_Placed__c, OR(INCLUDES(Role__c, "Manager"), INCLUDES(Role__c, "Sales Engineer"), INCLUDES(Role__c, "Support")))

 

The Order_Placed__c field is one of the checkboxes.  As you can see, I'm trying to select a just few of the roles for this workflow, rather than sending it to all of the contacts in the child records.

 

The action for this workflow is an email alert to the contact on the child object.

 

Unfortunately, this doesn't actually work.  If I have a master record with a checked box, and I create a new child record, I get the email alert.  However, if I repeatedly check and uncheck the field on the master object, I never get the email alert.

 

Has anyone done something like this before?  Can you point me in the right direction?  I'm comfortable with APEX code and I have a few ideas for hacking my way around this; but, I'd prefer to make this work with the standard workflow UI rather than hard-coding the logic elsewhere.

 

Thanks!

I've recently deployed a new VF page and controller which are exhibiting very odd behavior.  The page and controller make use of other components and classes, which all work in other contexts (hooray for code re-use).  However, when my users load this new page, they get an "Insufficient privileges" error.  In an attempt to figure out what was missing, I went through every single security setting in the profiles, and I have determined that the "View all data" admin privilege is required for my new page and controller to not give the security error.  I determined this by granting all permissions to every object in my whole org - CRUD, view all, and modify all - to the affected users' profile.  That didn't work.  Adding the "View all data" permission does work, even after taking away all the permissions I'd expect not to need.  So, in essence, my page & controller really do need "View all data" for some inexplicable reason.

 

Having looked through all the code, I'm only querying standard & custom objects - I can't imagine why "view all data" is required, especially since most of the code is shared and works properly in other contexts.  The only DML done during construction is select statements.  I added a try/catch in the page controller's constructor around all the code there, in an attempt to catch the security exception and display it, but that didn't change the error at all.  I got my user to give my login permission, but in order to view the system log (and thus figure out what's going on), I need to have the "view all data" permission... so when logged in as the user, I can't both reproduce the problem and debug it.  Argh!

 

As a short-term work-around I've changed to using "without sharing" on all of the related classes.  That seems to have worked, but isn't viable in the long-term.  Has anyone else run into this before?  Is there anything in the schema that could possibly require "view all data" to query?

 

I'm hoping one of the salesforce developers will read this - if so, my case # is 04306977.

 

I'm trying to calculate the number of days based on total hours in a month for an 8 hour workday.

 

For example, if there are 40 hours specificed for a month: 40 / 8 = 5 days

 

The problem is when I'm calculating hours that have a remainder.

 

For example, if there are 12 hours for a month: 12 / 8 = 1.5 days

 

Or, if there are 25 hours for a month: 25 / 8 = 3.125 days

 

Or, if there are 4 hours for a month: 4 / 8 = 0.5 days

 

Anytime there is a remainder, the calculation should round to the next highest integer value.

 

1.5 should round to 2

3.125 should round to 4

0.5 should round to 1

etc.

 

Here is what I was trying:

 

 

Integer recurrenceInterval = math.round((s.Hours__c / 8)-1);                

Integer hours = math.round(s.Hours__c);                

Integer remainder = math.mod(hours,8);                

if (remainder > 0) {                    
recurrenceInterval = recurrenceInterval + 1;                
}

 

My code isn't adding the necessary day in some instances.

 

Thanks for any help.

 

Hello,

I am trying to develop a page that shows the records of a custom object in a panelGrid according to a filter, where the user specifies values for the object's fields. I want to write a controller extensions that fetches the records from the Database using SOQL, but I need to get the values from the page, after the user types it. It probably will be something like [select field1, field2 from customobject__c where field1 = :ApexPages.currentPage().... (i don't know the rest)]

Thanks

Hello Everyone, I created some formula field and i try to merge all the field using IF condition, but it Showing error because its to large. So i try to update the field using Apex trigger.

This is my trigger:

 

trigger TimeZone on Contact (before insert, before update) {

 for (Contact cc : Trigger.new)
 
 {
  if(cc.SP_Place_TimeZone__c =='GMT+05:30')
   {
     cc.Customer_Place_Time__c = cc.Customer_Place_Time1_del__c;
   }
    if(cc.SP_Place_TimeZone__c =='GMT+00:00')
      {
       cc.Customer_Place_Time__c = cc.Customer_Place_Time_00_00_del__c;
      }
    if(cc.SP_Place_TimeZone__c =='GMT+01:00')
      {
       cc.Customer_Place_Time__c = cc.Customer_Place_Time_01_00_del__c;
      }   
   if(cc.SP_Place_TimeZone__c =='GMT+03:00')
      {
       cc.Customer_Place_Time__c = cc.Customer_Place_Time_03_00_del__c;
      }
}
}
Actually i created 10 formula field like that only :

IF( SP_Place_TimeZone__c ="GMT+00:00" && ISPICKVAL(Customer_place_Time_Zone__c, 'GMT+01:00'), NOW()+(0.041667) ,

IF(ISPICKVAL(Customer_place_Time_Zone__c, 'GMT+02:00'), NOW()+(0.833333),

IF(ISPICKVAL(Customer_place_Time_Zone__c, 'GMT+03:00'), NOW()+(0.125),

IF(ISPICKVAL(Customer_place_Time_Zone__c, 'GMT+04:00'), NOW()+(0.166667),

IF(ISPICKVAL(Customer_place_Time_Zone__c, 'GMT+05:00'), NOW()+(0.208333),

IF(ISPICKVAL(Customer_place_Time_Zone__c, 'GMT+06:00'), NOW()+(0.25),
)))))))

The main problem is Customer dont want to edit record, he want to just refresh record and update the field.

Can any one help me on this...Please. Please..

Thanks in advance :manhappy:

Can any one give sample example on schedule apex class???

I am getting a ‘Regex too complicated’ error below when loading data into our org using the following process:

 

1) an email service to receive the CSV data,

2) an APEX class to split and validate the CSV data, and then

3) a set of @future calls to upsert the data.

 

The same data works in smaller volumes, but not beyond a certain threshold. This applies whether we reduce the number of rows, or reduce the width of certain columns of data by truncating them to 3000 characters (a small number of columns have 10,000 characters of text included). When we do either or both of these steps in any combination to reduce the file size, we don't get this problem. It’s not a problem with a specific badly formatted row either, because reducing the number of rows in various combinations always causes the problem to go away.

 

So we don’t believe it is actually a regex problem, because the regular expression is just finding commas to split up a comma separated file/string - i.e. it's very simple.

 

This is why we think there's an undocumented storage or capacity limit somewhere within the APEX processing that is being exceeded - but one that doesn't have a governor limit associated with it, or indeed an accurate error message. We think it is an erroneous error message - i.e. it's not to do with complicated regex – and that this error message is a symptom of another issue.

 

This error has occurred in code that has been stable to date, but has appeared since the filesize we're uploading has increased to beyond about 4600-4800KB, which seems to be the threshold beyond which this problem occurs. There seem to be some undocumented limits in the volume of data than can be processed using the solution architecture we've designed.

 

We want to be able to code around this problem, but unless we know exactly what the error is, any changes we make to our code may not actually fix the problem and result in wasted effort. So I don't want to start changing this until I know exactly which part of the solution needs to be changed!

 

I’ve raised this with Salesforce as a potential bug or to see if they could clarify any undocumented limits on processing large volume datasets using the process we’ve designed, but they seem to have decided it’s a developer issue so won’t help.

 

The error message is below:

 

Apex script unhandled exception by user/organization: 

Failed to invoke future method 'public static void PrepareCSV(String, String, String, Integer, Boolean)'

caused by: System.Exception: Regex too complicated

Class.futureClassToProcess.GetList: line 98, column 17
Class.futureClassToProcess.parseCSV: line 53, column 38
Class.futureClassToProcess.PrepareCSV: line 35, column 20 External entry point

 The relevant code snippet is below:

 

 

 

public static list<List<String>> GetList(String Content)
        {
        Content = Content.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
            Content = Content.replaceAll('""','DBLQT');
            List<List<String>> lstCSV = new List<List<String>>();
            Boolean Cont = true;
            while (Cont == true){
                List<String> lstS = Content.Split('\r\n',500);
                if(lstS.size() == 500){
                    Content =lstS[499];
                    lstS.remove(499);
                }else{
                    Cont = false;
                }
                lstCSV.add(lstS);
            }
            return lstCSV;
        }

 

Any suggestions gratefully received as to whether we're missing something obvious, whether 4MB+ files just can't be processed this way, or whether this might actually be a SFDC APEX bug.

 

 

 

public static list<List<String>> GetList(String Content)
        {
            //Sanjeeb
            Log('GetList started.');
            Content = Content.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
            Log('Replaing DBLQT.');
            Content = Content.replaceAll('""','DBLQT');
            Log('Replaing DBLQT.');
            List<List<String>> lstCSV = new List<List<String>>();
            Boolean Cont = true;
            while (Cont == true){
                List<String> lstS = Content.Split('\r\n',500);
                Log('Split upto 500 Rows.');
                //List<String> lstS = Content.Split('\r\n',1000);
                if(lstS.size() == 500){
                    Content =lstS[499];
                    lstS.remove(499);
                }else{
                    Cont = false;
                }
                lstCSV.add(lstS);
            }
            Log('GetList ends.');
            return lstCSV;
        }

Can anyone clue me in on how to bring an attachment down from SF so my users can download to their machine?

 

I understand how to query or retrieve from the attachment object and also understand the need to decode the base64 encoded body, but my attempts have gone nowhere thus far.  Here is my code:

//SF Header stuff require_once ($_SERVER["DOCUMENT_ROOT"].'/system/header_sforce.php'); //Grab an Attachement Id from the reqeust object $attid = $_REQUEST['attid']; //Query SF for the desired attachment $query = 'SELECT Id, ParentId, Name, BodyLength, Body FROM Attachment WHERE Id = \''.$attid.'\' '; $queryObject = $mySforceConnection->query($query); //Probably have some header() methods here echo base64_decode($queryObject->records[0]->Body);

 

I know it's not elegant, right now I'm just trying to get a rudimentary download working.  If someone could just cut and paste an example of some working code from their app that would be so awesome.

 

Thanks in advance.

 

 

 

 

 

Hello,

 

I am trying to test for a valid date format (mm/dd/ccyy) at the beginning of a text field with no luck.  I have the following formula- NOT(REGEX(Description , "^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d"))

and if I only put 01/01/2009 in the text field it works but if I put anything after the date it fails.  For example, 01/01/2009 - This is a test to validate the regular expression -- that does not work!

 

I thought the ^ checked only the beginning for a match?  Any help would be appreciated.  We have a free form text box and the business requires that every time an entry is made it must begin with the date that they enter the text.  I know my approach above is only validating for a format; therefore, if you can help me with that it would be a start.  However, if you could even help me confirm that the beginning of the text field has the current date that would be even better.  I do not want to auto populate it because they may have already entered it and that would create a dup date.

Hi there,
 
how is one supposed to create an "OpportunityPartner" object using the API? According to the Apex Explorer this object is only query-able and retrieve-able, so basically a readonly construction.
 
So, is creating/updating a new OpportunityPlan plain impossible is there just a trick that I'm unaware of? 
 
Cheers,
Harry
  • October 02, 2008
  • Like
  • 0