• pp11222
  • NEWBIE
  • 30 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 10
    Replies

Hi

 

I need to find out the previous working date based on the BusinessHours .

 

Example

 

Order Due Date : Sunday, March 10, 2013

 

I need to get its previous working date which would be Friday, March 08,2013.

 

Also I want to make sure that if Friday was an holiday then it should return me Thursday, March 07,2013.

 

I have already looked at the business hours class  (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_businesshours.htm)

 

I was able to get the next buisiness day but not the previous buiseness day.

 

This is very urgent, I will appreciate if some one can provide me sample code for this.

 

Thanks

 

 

Hi

 

We have a Managed release package which was created a 3-4 years ago. We have already created several version of it and we have lot of customers usign different versions.

 

I want to know, is it a good idea to set the API versions for all of its Apex code, VF pages.. to latest (e.g. 26.0 or 27.0 after spring release) When we create our next package.

 

Thanks

Hi

 

We have a Managed release package which was created a 3-4 years ago. We have already created several version of it and we have lot of customers usign different versions.

 

I want to know, is it a good idea to set the API versions for all of its Apex code, VF pages.. to latest (e.g. 26.0 or 27.0 after spring release) When we create our next package.

 

Thanks

 

 

 

We have some developement work done in another DE org. We want to bring those the new custom objects in to our main DE org.

 

The custom objects are master child objects and they also have several rollup summary fields.

 

I would like to know how we can bring these Custom Objects from one DE org to another DE org which are not connected together.

 

Thanks

 

 

We have some developement work done in another DE org. We want to bring those the new custom objects in to our main DE org.

 

The custom objects are master child objects and they also have several rollup summary fields.

 

I would like to know how we can bring these Custom Objects from one DE org to another DE org which are not connected together.

 

Thanks

 

 

I want to know if is there a way to get the customer portal user's account id witout querying the User object for the the customer portal user.

 

Also what is the best way to find out if the logged in user is an customer portal user.

 

I could not find a system method to get account id using UserInfo.

 

Thanks

 

 

We have a situation where we need to execute multiple apex classes based on the current record id using a custom button on the detail page layout.

 

these actions will have DML statements with heavy calcuations and updates on multiple objects

 

We do not want to take any user inputs or an intermediate button clicks. We just want the user to click on the custom button, then this page should execute the apex classes and redirect back to the records detail page.

 

Please let me know any ideas and if possible some exeample codes.

 

Thanks

how to do the exception handling in a global void  apex class, which can be consumed by VF page or other apex classes.

 

I have some global void apex classes which were created in a manged release packages and now I cannot change their signatures or return value. These classes are called from VF pages and are also avaiable for other customers so that can use them in their custom code. but they do not have proper exception handling.

 

I want to know how can I trap the exceptions (DML Exceptions) in other classes or VF Pages.

 

Please provide some sample code.

 

Thanks

Is there a way to  determine if apex code is executed from visualforce page.

 

I have some classes which have calls to ApexPages methods and they give run time errors when they are not called from VF page.

 

Thanks

 

We have 2 custom objects

 

Order Line
Inventory Allocations

 

Inventory Allocation has a lookup relationship to Order Line

 

When Order Line is created then it may create inventory allocation records when inventory is available.

 

So there can be situations where a order line has no inventory allocations.

 

How can I query the order lines which does not have any inventory allocations.

 

I need to create a VF page which shows these records and process the records to create new inventory allocations.

 
 I am looking for ability to do something similar to this
 
SELECT o.Id, o.nAME FROM OrderLine__c o
where (select count() from gii__InventoryAllocation__c where OrderLine__c = o.id) = 0
 
So that I can get a list of Order Lines and I can display them in a VF page
 
 

I have 2 custom objects

 

Order Line
Inventory Allocations

 

Inventory Allocation has a lookup relationship to Order Line

 

When Order Line is created then it may create inventory allocation records when inventory is available.

 

So there can be situations where a order line has no inventory allocations.

 

How can I query the order lines which does not have any inventory allocations.

 

I need to create a VF page which shows these records and process the records to create new inventory allocations.

 

thanks

Hi

 

I need to add a In Line VF page with Google's V3 Maps API. I already have a s-control with v2 api but it requires a Google Map API Key.

 

Can someone please provide an example of Inline VF page with Google's V3 Maps API, so that I can show Google map for a address and include this page on a detail page layout.

 

 

Thanks

I am trying to use the new system method "isRunningTest". This is introduced from winter'11.

 

isRunningTest

Return Type : Boolean

Description: Returns true if the currently executing code was called by code contained in a method isRunningTest Boolean defined as testMethod, false otherwise. Use this method if you need to run different code depending on whether it was  being called from a test.

 

I have added folloiwng to one of my apex trigger

 

system.debug(' isRunningTest : '  + system.isRunningTest());

 

I am getting this error:

 

Error: Compile Error: Method does not exist or incorrect signature: system.isRunningTest() at line.

 

I have set the API version to 20.0 and I am still getting the same error

 

Has anyone already tried using it in the apex code

thanks

 

 

I have a requirement to create a visuaforce page which shows data with is parent-child (one-to-many) relationships.

This scenario gets a little more complex if any of the child records contain children of their own (i.e.,  grandkids).  

 

For example, a bicycle is a top-level assembly that contains parts such as posts, wheels brakes and more.  Each of these parts can also contain multiple parts.   A wheel is a sub-assembly of the bicycle which  is composed of a rim, tire, spokes etcetera.  These sub-assemblies can further contain component parts and sub-assemblies of their own (e.g.,  hubs, chain rings and bearings).    

A Parts List table is used to store child records for the parts, relating them to parent records with a key field such as Parent Assembly ID.  

 

this is more like a bill of material.  For example (Indenture Level in parentheses):

                    -Bicycle (0)
                          - Wheel assembly (1)
                                - Rims (2)
                                - Tires (2)
                                - Hub assembly (2)
                                      - Sprockets (3)
                                      - Derailier (3)
                                      - Etc. (3)
                          - Brake assembly (1)
                                - Pads (2)
                                - Cables (2)
                                - Etc. (2)
                         - Etc (1)

 

 

 

I will really appreciate if some one can post an example of VF page and Apex controller to achive this.

 

Thanks

 

 

 

Hi ,

 

I have one requirement that,

 

How Can We get Holidays from particular Business Hours  in Apex?

 

What is the Relation between Holidays and Business Hours please do some help

 

Thaks.

  • March 21, 2013
  • Like
  • 0

 

 

 

We have some developement work done in another DE org. We want to bring those the new custom objects in to our main DE org.

 

The custom objects are master child objects and they also have several rollup summary fields.

 

I would like to know how we can bring these Custom Objects from one DE org to another DE org which are not connected together.

 

Thanks

 

 

We have some developement work done in another DE org. We want to bring those the new custom objects in to our main DE org.

 

The custom objects are master child objects and they also have several rollup summary fields.

 

I would like to know how we can bring these Custom Objects from one DE org to another DE org which are not connected together.

 

Thanks

 

 

Hi every one,

 

i wrote trigger on glovia OM manage package.Now i am writting test class for those trigger then i am getting error like this-

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, System policy record is missing for glovia OM Application or you may not have access to it. Please contact your system administrator.: []

 

Trigger-

 

trigger TreatmentPrice on Treatments__c (After Insert,After Update,before Delete)
{
//Limit the size of list by using Sets which do not contain duplicate elements
set<ID> SQIds = new set<ID>();
set<ID> PTIDs=new set<ID>();
set<string> PFamily=new set<string>();
//When adding new create invoice or updating existing quote

if(trigger.isInsert || trigger.isUpdate)
{
for(Treatments__c p : trigger.new)
{
SQIds.add(p.Sales_Quote_Id__c);
PTIDs.add(p.Treatment_Name__c);
}

//Map will contain one quote Id to one Count value(no of Invoice)
map<Id,Decimal> SalesQuoteMap = new map<Id,Decimal>();
map<Id,Decimal> SalesQuoteMap1 = new map<Id,Decimal>();
try{
List<Treatments__c > PF=[select id,Treatment_Name__c from Treatments__c where Sales_Quote_Id__c IN :SQIds AND Treatment_Name__c IN :PTIDs ];
//use group by to have a single appointment Id with a single sum value
for(AggregateResult q : [select Sales_Quote_Id__c,SUM(Total_Price__c) from Treatments__c where Sales_Quote_Id__c IN :SQIds group by Sales_Quote_Id__c])
{
SalesQuoteMap.put((Id)q.get('Sales_Quote_Id__c'),(Double)q.get('expr0'));
}
/*for(AggregateResult q : [select Sales_Quote_Id__c,SUM(Credit_Adjustments__c) from Treatments__c where Sales_Quote_Id__c IN :SQIds group by Sales_Quote_Id__c])
{
SalesQuoteMap1.put((Id)q.get('Sales_Quote_Id__c'),(Double)q.get('expr0'));
}*/

List<gii__SalesQuote__c> SalesQuoteToUpdate = new List<gii__SalesQuote__c>();

//Run the for loop on Sales Quote using the non-duplicate set of Sales quote Ids
for(gii__SalesQuote__c o : [Select Id,Treatment_Discount__c,Estimated_cost__c from gii__SalesQuote__c where Id IN :SQIds])
{
Double QuoteCount = SalesQuoteMap.get(o.Id);
//Double Discount = SalesQuoteMap1.get(o.Id);
//o.Treatment_Discount__c= Discount;
o.Estimated_cost__c =QuoteCount ;

SalesQuoteToUpdate.add(o);
}
update SalesQuoteToUpdate;
}
Catch(Exception e)
{
//ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Please check treatment object');
//ApexPages.addMessage(myMsg);
for(Treatments__c t :trigger.new)
{
//t.addError('Please check treatment object');
}
}
}

//When deleting created quote
if(trigger.isDelete)
{
for(Treatments__c p : trigger.old)
{
SQIds.add(p.Sales_Quote_Id__c);
system.debug('Quote id'+SQIds);
PFamily.add(p.Name);
}
//Map will contain one appointment Id to one Count value(no of Invoice)
map<Id,Decimal> SalesQuoteMap = new map<Id,Decimal>();
map<Id,Decimal> SalesQuoteMap1 = new map<Id,Decimal>();
List<Treatments__c > PF=[select id,Name,Sales_Quote_Id__c from Treatments__c where Sales_Quote_Id__c IN :SQIds AND Name=:PFamily];

//use group by to have a single Quote Id with a single sum value
if(PF.size()>0)
{
for(AggregateResult q : [select Sales_Quote_Id__c,SUM(Total_Price__c) from Treatments__c where Name=:PFamily AND Sales_Quote_Id__c IN :SQIds group by Sales_Quote_Id__c])
{
SalesQuoteMap.put((Id)q.get('Sales_Quote_Id__c'),(Double)q.get('expr0'));
}
/*for(AggregateResult q : [select Sales_Quote_Id__c,SUM(Credit_Adjustments__c) from Treatments__c where Name=:PFamily AND Sales_Quote_Id__c IN :SQIds group by Sales_Quote_Id__c])
{
SalesQuoteMap1.put((Id)q.get('Sales_Quote_Id__c'),(Double)q.get('expr0'));
}*/

List<gii__SalesQuote__c> SalesQuoteToUpdate = new List<gii__SalesQuote__c>();

//Run the for loop on sales quote using the non-duplicate set of Quote Ids
for(gii__SalesQuote__c o : [Select Id, Treatment_Discount__c,Estimated_cost__c from gii__SalesQuote__c where Id IN :SQIds])
{
Double QuoteCount = SalesQuoteMap.get(o.Id);
//Double Discount = SalesQuoteMap1.get(o.Id);
//o.Treatment_Discount__c= o.Treatment_Discount__c-Discount;
o.Estimated_cost__c =o.Estimated_cost__c-QuoteCount;
SalesQuoteToUpdate.add(o);

}
update SalesQuoteToUpdate;
}
}
}

 

//Test class

 

@isTest
private class testRollUpNoOfTeatmentQuote
{
    static testMethod void countNoOftreatmentQuote()
    {
        Datetime myDate = datetime.newInstance(2008, 2, 5, 8, 30, 12);
        Profile pf = [Select Id from Profile where Name='System Administrator'];
        User u = new User();
        u.FirstName='Test';
        u.LastName='User';
        u.Email='shiv@test.com';
        u.CompanyName='KVP';
        u.Title='Software Engineer';
        u.Username='shiv@kvpcorp.com';
        u.Alias='test';
        u.communityNickName='kvpian';
        u.TimeZoneSidKey='America/Mexico_City';
        u.LocaleSidKey='en_US';
        u.EmailEncodingKey='ISO-8859-1';
        u.ProfileId=pf.Id;
        u.LanguageLocaleKey = 'en_US';
        insert u;
        //creating clinic record
        Clinic__c cl = new Clinic__c(Name = 'Ajax');
        insert cl;
        //creating clinic record
        Referral_Card__c r = new Referral_Card__c(Name = 'XXX123',Referral_Card_Type__c='rty');
        insert r;
        //creating staff record
        Staff__c staff = new Staff__c(Name = u.id,User_Name__c=u.id);
        insert staff;
        //creating rsource record
        Resource__c resource = new Resource__c(Name = 'X-rayMachine',Clinic__c=cl.Id);
        insert resource;
        //creating staff schedule record
        Staff_Schedule__c staffSchedule = new Staff_Schedule__c(Staff__c=staff.id, Shift_Start__c=myDate,Shift_Endds__c=myDate.addDays(1), Clinic__c=cl.id);
        insert staffSchedule;
        //creating resource schedule
        Resource_Schedule__c resourceSchedule = new Resource_Schedule__c(Close_Time__c=myDate.addDays(1), Open_Time__c=myDate, Clinic__c=cl.id,Staff_Name__c=staff.id, Name__c = resource.id);
        insert resourceSchedule;
        //Creating record for patient
        contact p= new contact(FirstName='Michel',No_of_Appointment__c=1,No_Of_Webcam_Used__c=1, LastName='Methew',Email='Michel@gmail.com', Status__c='open', Preferred_Phone_Number__c='12345678', LeadSource='ccr');
        insert p;        
        //creating record for treatment
        Treatments1__c t= new Treatments1__c(Name='SkinTightning', Resource_Name__c= resource.id,Type__c='Treatment',Price__c=100);
        insert t;
        //Creatting appointment record
         opportunity o=new opportunity(Clinic__c=cl.Id,Treatment_Name__c = t.Id, Name='testAppointMent', CloseDate=system.Today(), Appointment_Start_Date_Time__c=myDate,Appointment_End_Date_Time1__c=myDate.addDays(1),StageName='booked', Resource__c=resource.id, Patient_Name__c=p.id);
        insert o;
        //Createing record for Campaign
        Campaign c= new Campaign(Name='XYZ');
        insert c;        
        //Createing record for Account
        Account a= new Account(Name='Skin Vitality');
        insert a;
        //Creating treatment pitch record
        Treatment_Pitch__c tp=new Treatment_Pitch__c(Name='maintenance',Treatments__c=t.id,Treatment_Number__c=1);
        Insert tp;
        //Create sales Quote
             gii__SalesQuote__c SQ = new gii__SalesQuote__c(     
                                                                    Customer_Name__c=p.Id,
                                                                    Appointment_Name__c=o.Id,
                                                                    Medical_Representative__c=staff.Id,
                                                                    Estimated_cost__c=50,
                                                                    Status__c='Invoiced',
                                                                    gii__Account__c=a.id                   
                                                                    );
                    
                     insert SQ;
          //Create invoice     
              if(SQ.Status__c=='Invoiced')  
                  {             
                   
                        Invoices__c Inv = new Invoices__c (
                                                            Sales_Quote_Id__c=SQ.Id,
                                                            Contact_ID__c=p.Id, 
                                                            Appointment_Name__c=o.Id                  
                                                              
                                                           ); 
                        insert Inv;   
                  }
           //Create treatment   
                if(SQ.Status__c=='Invoiced' && t.Type__c=='Treatment')  
                  {             
                   
                        Treatments__c  Trt= new Treatments__c(
                                                            Treatment_Name__c=t.Id,
                                                            of_Treatment__c=2,                    
                                                            Sales_Quote_Id__c=SQ.Id  
                                                           ); 
                        insert Trt;   
                  }
             //Update sales quote     
                gii__SalesQuote__c SQ1 = [select Estimated_cost__c from gii__SalesQuote__c  limit 1];
                List<gii__SalesQuote__c> QuoteListToUpdate =new List<gii__SalesQuote__c>();
                for(integer i=0 ; i<250 ;i++)
                {  
                    SQ1.Estimated_cost__c = 200;                    
                    QuoteListToUpdate.add(SQ1);
                    Update QuoteListToUpdate ;
                }
                
                
                //delete TreatmentListToInsert[0];
           
       
     }   
}

 

 

 

Please help me to solve this problem.

 

Regards,

DD

I have 2 custom objects

 

Order Line
Inventory Allocations

 

Inventory Allocation has a lookup relationship to Order Line

 

When Order Line is created then it may create inventory allocation records when inventory is available.

 

So there can be situations where a order line has no inventory allocations.

 

How can I query the order lines which does not have any inventory allocations.

 

I need to create a VF page which shows these records and process the records to create new inventory allocations.

 

thanks

Hi

 

I need to add a In Line VF page with Google's V3 Maps API. I already have a s-control with v2 api but it requires a Google Map API Key.

 

Can someone please provide an example of Inline VF page with Google's V3 Maps API, so that I can show Google map for a address and include this page on a detail page layout.

 

 

Thanks

I am trying to use the new system method "isRunningTest". This is introduced from winter'11.

 

isRunningTest

Return Type : Boolean

Description: Returns true if the currently executing code was called by code contained in a method isRunningTest Boolean defined as testMethod, false otherwise. Use this method if you need to run different code depending on whether it was  being called from a test.

 

I have added folloiwng to one of my apex trigger

 

system.debug(' isRunningTest : '  + system.isRunningTest());

 

I am getting this error:

 

Error: Compile Error: Method does not exist or incorrect signature: system.isRunningTest() at line.

 

I have set the API version to 20.0 and I am still getting the same error

 

Has anyone already tried using it in the apex code

thanks

 

 

I've created a hierarchical Custom Setting.  I'm looking to modify a field at the org level.

 

Given that my custom setting is called Test_config__c, and the field I want to update is Sample_field__c, here is some sample code:

 

 

Test_config__c aConfig = Test_config__c.getOrgDefaults();

aConfig.Sample_field__c = 'Some new value';

 

 

When I manage the custom value, the assignment hasn't been persisted.