• avimeir
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 45
    Questions
  • 22
    Replies

Hi All,

 

Any idea where is the language of Template Source Org for Trialforce determined? 

 

We are creating a new TSO from our TMO, and it gets all the reports, dashboards, in Spanish.

 

Any idea why?

Hi all,

 

I have a managed package with 40 custom objects and arouns 20 VF pages. Right now when users install it, system admins can access all pages, but Salesforce Platform Users can't see some of my VF pages, they get the error:

 

"

Insufficient PrivilegesYou do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary"

 

 

Any idea how I can enable ALL pages and objects quickly for any user?

 

I had a look at the permission sets feature, but unless I am missing something, it seems that I need to go object-by-object and modify each one of them, there must be a better way...

 

Thanks

Hi all,

 

We have an object called Payment__c  and it has a datetime field called Payment_Time__c.

 

A user is asking to create a report and filter the results by the time of the day of Payment_Time__c - only show results if Payment_Time__c > 1/1/2014 10:00 and Payment_Time__c < 1/2/2014 10:00.

 

Is there a way to filter by time of day in reports?

 

I thought of an ugly hack of a forumla field taking the time from the Payment_Time__c field, but I hate this solution. Wanted to use the datetime method format('HH:MM') to create a new forumla field and filter by it, but can't seem to use this method in a formula field.

 

Any ideas?

Hi all,

 

Any idea how to align two inputField within a <fieldset> on the same line, without using <table> ?

 

 

Hi,

 

How can I get a string representing today's date in the format YYYYMMDD ?

 

Thanks

Hi all,

 

I always found the idea of Views good, but the implementation is far from being user friendly. For example - my users want to filter the custom object Reservation__c by certain properties, and the only way they can do it is by creating a new View. The problem is that the create new view concept and screen is scary for non-tech savyy users.

 

Is there a way to add filters to a tab list view that goes around the need to create new views by the user?

 

For example - allowing to filter by dates, or by status, or by amount paid etc. (all are custom properties of a custom object).

 

One option I thought of is to create a completely new VF page and do this from scratch, but I am trying to avoid re-creating the entire filtering feature.

Hello,

 

I would like to sum up fields from two different custom objects, no idea how to do it without ugly hacks of converting to decimal. I want to keep the sObject so that I can use it in an apex:outputField as this is a currency field and I need the currency sign.

 

Here's how I get the two sums today. Any idea how to sum both fields into one sObject?

 

Thanks

 

  	    list <AggregateResult> resRooms = [SELECT SUM(Price__c) FROM ReservationRoomAssociation__c WHERE Rooms__c = :getReservationId()];
   		list <AggregateResult> resBeds = [SELECT SUM(Price__c) FROM BedReservationAssociation__c WHERE Reservation__c = :getReservationId()];

 

Hi All,

 

I have a relatedList for a custom object called Invoice__c. I have overridden the View page with a custom VF page, and would like now to open it in a new browser tab when the user clicks on the Invoice item in the related list. Is there a way to make it happen without recreating a custom related list from scratch?

 

Thanks

Hi,

 

I have a custom object called Reservation__c that has a picklist Status__c.

 

I've created a custom button from the detail page that opens a new window to a custom VF page, where the user can change attributes of Reservation__c. On that page, the user can click Save, which does APEX update to the relevant Reservation__c object and window.top.close() to return to the Reservation__c detail page. Once the window is closed, I do a JS refresh of the Reservation__c page to show the changes of the object.

 

The problem is that it takes a few seconds for the change of Status__c to be seen in the Reservation__c page. I suspect that this is due to a delay in the database write backlog. If I wait 2-3 seconds and then manually refresh, the correct changes can be seen. 

 

Any idea on how to solve this issue?  I want the changes to be shown after the automatic refresh, and I want this automatic refresh to be done as soon as the database is updated.

 

Thanks

Hi all,

 

I have an object Services that connects two custom objects using master-detail relationship.

 

I've built a VF page and want to add a related list for this object. How do I do it?

 

Tried 

    <apex:relatedList list="Services" />

 But nothing shows.

 

Thanks

Hi all,

 

I have the following VF page:

 

<apex:page controller="CheckAvailController">

<apex:sectionHeader title="Check Availabilities"/>
<apex:pageblock >
    <apex:form >
        <apex:outputLabel value="From: " for="fromDate"/><apex:inputField id="fromDate" value="{!availFrom.Date__c}" />
        <apex:outputLabel value="To: " for="toDate"/><apex:inputField id="toDate" value="{!availTo.Date__c}" />
        <apex:commandButton action="{!search}" value="Search" />
    </apex:form>
    <apex:pageBlock >
        <apex:pageBlockTable value="{!availabilities}" var="avail">
            <apex:column value="{!avail}" />
        </apex:pageBlockTable>
    </apex:pageBlock>

</apex:pageblock>

</apex:page>

 

And I want to embed this into the details page of the custom Reservation__c object, can't seem to find a way to do it. I tried changing the apex:page tag into:

<apex:page controller="Reservation__c" extensions="CheckAvailController">

 But it doesn't accept Reservation__c as controller.

 

What am I missing?

 

Thanks

Hi all,

 

I am getting the error: 

 

Error:Apex trigger handleReservationChange caused an unexpected exception, contact your administrator: handleReservationChange: System.LimitException: Too many SOQL queries: 101

 

I know that it's wrong to have the SOQL queries inside the for loops, but can't understand how to perform what I need otherwise. Could someone please post a code sample of how I could take the SOQL queries outside of the loops?

 

 

private static void assignPricesToReservation (ReservationRoomAssociation__c assoc)
    {
    	Double todayRate = 0;
		Date currentDay;
		
		System.debug('adding assoc ' + assoc);
		
		// Initialize price
		assoc.Price__c = 0;
		
          
        // Get room type                            
		Room_Type__c rt = [SELECT Name,Number_of_Rooms__c, Default_Rate__c, Id
		 				   FROM Room_Type__c 
		 				   WHERE Id = :assoc.Room_Type__c LIMIT 1];
		System.debug('found roomtype ' + rt);		 
		String roomType = rt.Name;
		System.debug('Room type is ' + roomType);
		
		// Get reservation
		Reservation__c resa = [SELECT Total_Nights__c, Check_In__c, Check_Out__c, Total_Price__c
		 					   FROM Reservation__c 
		 					   WHERE Id = :assoc.Rooms__c LIMIT 1];
	        
        // Add price per night    
		for (Integer i = 0; i < resa.Total_Nights__c; i++)
        {
            currentDay = resa.Check_In__c.addDays(i);          
            System.debug('Date: ' + currentDay);
           
            // Check for availability for the night
            try 
            {      
                Availability__c avail = [SELECT Name, Rooms_Available__c,Room_Type__c 
                                         FROM Availability__c 
                                         WHERE Date__c = :currentDay AND Room_Type__r.Name = :roomType];

                // Yes, there is availability
                if (avail.Rooms_Available__c <= 0)
                {
                	throw new reservationException('No availablity for the selected dates');
                }		
                else
                {
                	// Remove one room from the total available rooms of this date / room-type match
                	avail.Rooms_Available__c -= 1;
                	update avail;
                }	    
		    }
		    catch (Exception e) 
			{
				// No availability record, create one
			    System.debug('no availability record, creating a new one with max rooms ' + rt.Number_of_Rooms__c);
			    Availability__c avail = new Availability__c ();
			    avail.Date__c = currentDay;
			    avail.Rooms_Available__c = rt.Number_of_Rooms__c - 1;
			    avail.Total_Rooms__c = rt.Number_of_Rooms__c;
			    avail.Room_Type__c = rt.Id;
			    insert avail;
			    	    			    
			}
			
			
			try 
            {
			    // Is there a specific rate for this day?
			    Date_Rate__c dateRate = [SELECT Price__c
			    						 FROM Date_Rate__c
			    						 WHERE Date__c = :currentDay
			    						 AND Room_Type__r.Name = :roomType
			    						 ];
				 if (dateRate != null)
				 {
				 	todayRate = dateRate.Price__c;
					System.debug('got date-specific rate for ' + currentDay + ' rt: ' + roomType + ' rate is: ' + todayRate);			 
				 }
			}
			catch (Exception e)
			{
			 	todayRate = rt.Default_Rate__c;    
				System.debug('couldn\'t find specific rate for ' + currentDay + ' using default rate: ' + todayRate);	 	
			}
			
	        // Add the rate for this date and room type   
	        System.debug('adding rate to the total price: ' + todayRate);   
	        assoc.Price__c += todayRate;
	          		
	        if (resa.Total_Price__c != null)
	        {
	        	resa.Total_Price__c += todayRate; 
	        }
	        else
	        {
	        	resa.Total_Price__c = todayRate;
	        } 
		            
        }
	    System.debug('New reservation total price is ' + resa.Total_Price__c);   
	    update resa;   	
    }
    
	private static void calculateReservationPrice (Reservation__c r)
	{
		try 
		{
			Reservation__c resa = [SELECT Total_Price__c FROM Reservation__c WHERE Id = :r.Id];
			resa.Total_Price__c = 0;
			update resa;
		}
		catch (Exception e)
		{
			System.debug('couldn\'t set reservation price to 0');
		}
		
		System.debug('calculating new reservation price');
				
		// Get all room associations for this resa
		List <ReservationRoomAssociation__c> assoc = [SELECT a.Id, a.Room_Type__c, a.Rooms__c
												      FROM ReservationRoomAssociation__c a
												      WHERE a.Rooms__c = :r.Id];
		
		System.debug('updating pricing for ' + r.Name);
		
		for (ReservationRoomAssociation__c a : assoc)
		{
			System.debug('Assigning price for association ' + a);
			assignPricesToReservation(a);
		}
	}
	public static void handleReservationChange(List <Reservation__c> oldResas, 
											   List <Reservation__c> newResas)
    {
    	System.debug('handleReservationChange');
    	
    	
    	Reservation__c oldResa;
    	// Check if reservation changed in length
    	for (Reservation__c r : newResas)
    	{
    		oldResa = null;
    		
    		// get the corresponding old resa
    		System.debug('in reservation iteration loop');
 
    		for (Reservation__c oldR : oldResas)
    		{
    			if (oldR.Id == r.Id)
    			{
    				oldResa = oldR;
    				break;
    			}
    		}
    		if (oldResa == null)
    		{
    			throw new reservationException('can\'t find old reservations');
    		}
    		
    		System.debug('old nights: ' + oldResa.Total_Nights__c + ' new nights: ' + r.Total_Nights__c);
    		
    		if (oldResa.Total_Nights__c != r.Total_Nights__c)
    		{
    			System.debug('calling caluclateReservationPrice for' + r);
    			calculateReservationPrice(r);
    		}
    	}
    	
    	
    }
    

 

Thanks!

 

Hi,

 

I have an object that creates association of two custom objects: Reservation and Room. I am trying to do something when a new association is created. This is the code I have:

 

trigger handleNewRoomResaAssociation on ReservationRoomAssociation__c (after insert) {
    for (ReservationRoomAssociation__c assoc : Trigger.New)
    {
        System.debug(assoc.Room__r.Name);
        
      
    }

}

 

The debug returns null, as if there is no Room__c object associated. What am I doing wrong?

 

Thanks

Hi

 

Is there a way to group a few custome tabs into one drop-down menu?

 

Thanks!

 

Avi

Hi 

 

I am trying to add a birthday to a Client custom object, but the date selector goes only as back as 2011. How can I add all years from 1920 to current year?

 

Thanks

Hi All

 

I am new to Force.com, trying to figure out a way to create a many-to-many relationship of objects.

 

I have two custom objects: Rooms and Reservations. A reservation can have zero or more rooms assigned to it, and a room can be assigned to zero or more reservations.

 

I tried using Master-Detail but it requires a single assignment on one of the objects, instead - I want to have lists on both objects, that can be empty or have more than 1 items.

 

Thanksq

Is there a way to put multiple input fields on the same line of a page?  E.g. LastName and Suffix__c on the same line.

 

Thanks

David