• Ajay.Dixit
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Can we display Salesforce site in mobile.

I wanted to use Salesforce to create a Force.com site which displays some data in tabular form. I want to acess this site through mobile.

Can we display Salesforce site in mobile.

I wanted to use Salesforce to create a site which displays some data in tabular form. I want to acess this site through mobile.

I know when we create  Detail Object from Master Related List through Standard "NEW" button Lookup to master gets prepopulated. if I want to acheive same through "NEW" button which come after click of child object tab i.e. prepopulate with Lookup value is it possible. For information that master object unique for User Logged in.

When ever user is inactivated his mobile device should be automatically deleted or atleast all mobile data should be erased. I want to perform this programatically via trigger or Apex API call. is it possible. What is the object where Mobile Device information is stored. Does any body has any idea... Thanks in advance.

My vf page, requestCreate,  is working fine except for when the Cancel button is pressed the user is returned to the home page. I would like for the user to return to the requestCreate page. 

 

I cloned the RequestNewExtension from an existing extension.

 

I have Save and Cancel buttons:

<apex:pageBlockButtons location="both">
<apex:commandButton value="Save" action="{!Save}" />
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>

 

When the user chooses SaveI direct the user to a Thank You pagethat works fine.

 

I tried different codes for the Cancel button unsuccessfully. I would like to return the user back to the requestCreate page

 

Here is my extenstion:

public with sharing class RequestNewExtension {
    public String Comment
    {
        get;
        set;
    }
    public String Description
    {
        get;
        set;
    } 
    public String Subject
    {
        get;
        set;
    }
    public Boolean UseAssignmentRules
    {
        get;set;
    }
   
    public Case cs;
    ApexPages.StandardController controller;
   
    public RequestNewExtension (ApexPages.StandardController con)
    {
        controller = con;
        this.cs = (Case) con.getRecord();
    }
   
    public PageReference Save()
    {
        CaseComment com = new CaseComment();
        if(Comment.Length() > 0)
        {
            com.commentBody = Comment;
            com.ParentId = cs.Id;
            if(UseAssignmentRules == true)
            {
                AssignmentRule  AR = new AssignmentRule();
                AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
               
                //Creating the DMLOptions for "Assign using active assignment rules" checkbox
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
                controller.getRecord().setOptions(dmlOpts);               
            }
            insert com;
        }
        String retURL = ApexPages.currentPage().getParameters().get('retURL');
        String CurrentId = ApexPages.currentPage().getParameters().get('id');
        PageReference redirectPG;
        if(retURL != null)
            redirectPG = new PageReference('/' + retURL);
        else if(CurrentId != null)
            redirectPG = new PageReference('/' + CurrentId);
       
        controller.Save();
       
         return Page.Request_Create_Thankyou;
    }
 }

  • July 03, 2013
  • Like
  • 0

Hi, 

 

 I Recently developed a Trigger in SandBox which is working fine. I need to move this to production. But since it has 0% coverage. I am not able to deploy Please suggest me how to move this below code. 

 

 

trigger Updating_Lead_Contact_Field on CampaignMember (after insert, after update) {

 List<Lead> ldlist = new List<Lead>(); 
 List<Contact> ldContact = new List<Contact>(); 
 
 List<CampaignMember> lstCampaignMember = 
 [select id,campaign.Name,
         contactId,contact.Primary_Campaign__c,contact.Recent_Campaign__c,  
         LeadId,Lead.Primary_Campaign__c,Lead.Recent_Campaign__c
  from CampaignMember  
  where id in: trigger.newmap.keyset()];      

  for(CampaignMember cmpmember: lstCampaignMember)
        { 
         
    if ( cmpmember.LeadId != null){        
         
         if(cmpmember.Lead.Primary_Campaign__c == null)
          {
                cmpmember.Lead.Primary_Campaign__c = cmpmember.campaign.ID;
                cmpmember.Lead.Recent_Campaign__c = cmpmember.campaign.ID;
            }
            else
            {
                cmpmember.Lead.Recent_Campaign__c = cmpmember.campaign.ID;
            } 
            ldlist.add(cmpmember.Lead);              
        }
     
      if ( cmpmember.contactId != null){   
          if(cmpmember.Contact.Primary_Campaign__c == null)
          {
                cmpmember.Contact.Primary_Campaign__c = cmpmember.campaign.ID;
                cmpmember.Contact.Recent_Campaign__c = cmpmember.campaign.ID;                 
               
            }
            else
            {
                cmpmember.Contact.Recent_Campaign__c = cmpmember.campaign.ID;
            }   
           ldContact.add(cmpmember.Contact);             
        }             
            

        }

     
    if(ldlist !=null && ldlist.size()>0){
        upsert ldlist;
    }      
   
    if(ldContact !=null && ldContact.size()>0){
        upsert ldContact;
    }      
 
        
}

 

Thanks

Sudhir

Can we display Salesforce site in mobile.

I wanted to use Salesforce to create a Force.com site which displays some data in tabular form. I want to acess this site through mobile.

Hi, I am not a coder so I would very much appreciate some help on how to code the follow simple trigger (i think):

 

I have a custom object that embedded in the Opportunity object with master-detail relationship.

 

On this custom object I have created a custom look-up field to relate with the User object.

 

What I need is a trigger to auto-populate this "User " look-up field with the "Opportunity Owner" whenever a record is created on this custom object.

 

Please help me! thank you!!

  • May 23, 2013
  • Like
  • 0

This seems so simple but I can't get it to work.

 

I want to copy 2 fields from one object to another:

 

Move_To_State_Province__c on Move__c copied to Mailing_State__c on Client__c

Move_To_Country on Move__c copied to Mailing_Country__c on Client__c

 

I've cobbled together the code based on solutions here on the board.  It saves fine, but nothing happens.  What am I missing?  Also, once it works, how would you write a test for it?

 

Thanks!  I'm stumped!

 

trigger NewMailingStateAndCountry on Move__c (after insert, after update) {
    for(Move__c mov : Trigger.New){
        List<Client__c> listClient = [Select Mailing_State__c, Mailing_Country__c from Client__c];
        for(Client__c client : listClient){
            client.Mailing_State__c = mov.Move_To_State_Province__c;
            client.Mailing_Country__c = mov.Move_To_Country__c;
        }
        update listClient;
    }

}

 

I have implemented the standard list paging functionality and I've written my unit tests to cover the controller code.  My code is covered 100%, but I'm getting two errors on my asserts.

 

Here is my controller class:

 

public class BariatricEventsController {
	
	public ApexPages.StandardSetController setCtrl{get; set;}
  	
  	public BariatricEventsController()
 	{
   		setCtrl = new ApexPages.StandardSetController(Database.getQueryLocator([Select Name, Event_Date__c, Time_of_Event__c,Type__c,Service_Line__c, openSlots__c, SFDC_Facility__r.Name,Fee__c,Remaining_Space_Available__c,
                Maximum_Space_Available__c, Event_Status__c from SFDC_Event__c where (Event_Status__c ='Open' or Event_Status__c='Wait List' or 
                Event_Status__c='Closed') and Service_Line__c LIKE '%bariatric%' and Event_Date__c >= :System.today() and Event_Date__c <= :System.today().addDays(30) order by Event_Date__c]));
 		setCtrl.setPageSize(10);
 	}
  	
  	public Boolean hasNext {
  		get {
  			return setCtrl.getHasNext();
  		}
  	}
  	
  	public Boolean hasPrevious {
		get {
			return setCtrl.getHasPrevious();
		}
		set;
	}
  	
  	public Integer pageNumber {
		get {
			return setCtrl.getPageNumber();
		}
		set;
	}
	
	public Integer totalPages {
		get {
			Decimal totalPages = Decimal.valueOf(setCtrl.getPageNumber()).round(RoundingMode.CEILING);
			return totalPages.intValue();
		}
		set;
	}
  	
 	public void first() {
 		setCtrl.first();
 	}

 	public void last() {
 		setCtrl.last();
 	}

 	public void previous() {
 		setCtrl.previous();
 	}

 	public void next() {
 		setCtrl.next();
 	}
  	
  	
  	public List<SFDC_Event__c> getEvents()
  	{
    	return (List<SFDC_Event__c>)setCtrl.getRecords();
  	}

}

 Here is my unit test class:

 

@isTest
private class TestBariatricEventsController {

	private static testMethod void test() {
		
		SFDC_Facility__c sfdcfacility = new SFDC_Facility__c(name='Test Facility');
        insert sfdcfacility;
        
        Campaign camp = new Campaign(Name='Test',isActive=True, Approved__c=True, Type='Advertisement',Status='Planned',StartDate=Date.Today());
        insert camp;
		
		SFDC_Event__c sfdcevent = new SFDC_Event__c();
		sfdcevent.name='Test1';
		sfdcevent.Registration_Fee__c=0;
		sfdcevent.Service_Line__c='Bariatric Weight Loss Surgery';
		sfdcevent.type__c='Seminar';
		sfdcevent.event_status__c='Open';
		sfdcevent.Maximum_Space_Available__c=12;
		sfdcevent.Event_Date__c=System.today().addDays(15);
		sfdcevent.SFDC_Facility__c=sfdcfacility.Id;
		sfdcevent.Primary_Campaign__c=camp.Id;
		
		SFDC_Event__c sfdcevent2 = new SFDC_Event__c();
		sfdcevent2.name='Test2';
		sfdcevent2.Registration_Fee__c=0;
		sfdcevent2.Service_Line__c='Bariatric Weight Loss Surgery';
		sfdcevent2.type__c='Seminar';
		sfdcevent2.event_status__c='Open';
		sfdcevent2.Maximum_Space_Available__c=12;
		sfdcevent2.Event_Date__c=System.today().addDays(15);
		sfdcevent2.SFDC_Facility__c=sfdcfacility.Id;
		sfdcevent2.Primary_Campaign__c=camp.Id;
        
        List<SFDC_Event__c> evs = new List<SFDC_Event__c>();
		evs.add(sfdcevent);
		evs.add(sfdcevent2);
		insert evs;
        
        PageReference pageRef = Page.BariatricEvents;
		Test.setCurrentPage(pageRef);
		
		ApexPages.StandardSetController ssc = new ApexPages.Standardsetcontroller(evs);
		BariatricEventsController ctrl = new BariatricEventsController();
		ctrl.first();
		ctrl.getEvents();
		ctrl.last();
		ctrl.next();
		ctrl.previous();
		
		system.assertEquals(true, ctrl.hasNext);
		system.assertEquals(true, ctrl.hasPrevious);
		system.assertEquals(3, ctrl.pageNumber);
		system.assertEquals(3, ctrl.totalPages);
		
	}

}

 The assers fail on the following two lines:

 

system.assertEquals(1, ctrl.pageNumber);
system.assertEquals(1, ctrl.totalPages);

 The assers expect the value of 3 instead of 1?  But, my page size is set to 10 in my controller and I've only got two records in my list, so shouldn't the pageNumber and totalPages equal 1?

 

What am I missing?

 

Thanks for any help.

Apex repeat function here would repeat the days of the week, iterating from Monday to Sunday also displaying the day alongside.

My problem is in the prevWeek.

prevWeek is a button. (supposed to be)

When it is clicked I want the changes in goprev to take place.

I need wcTopBar to display the previous weeks days.

 

Pl take a look at

 <apex:actionSupport event="onclick" action="{!goprev}" rerender="wcTopBar" />  

and let me know what is deficient to do the job.

 

 

<apex:outputPanel id="wcTopBar" layout="block" styleClass="containerAD noscroll" style="height: 37px;">
                                    <div class="overflowContainer">    
                                        <div class="weekLabels">
                                            <apex:repeat value="{!daysOfWeek}" var="d">
                                                <div class="{!d.divClass}">
                                                    <div><span style="{!d.spanStyle}"><apex:outputText value="{!d.dayName}" escape="false" /></span></div>
                                                        </div>
                                            </apex:repeat>

___________________________________________________

<div class="prevWeek" id="prevweek">
                                            <a class="t_btn _background1Hover _border1 _background1 left small">
                                                <img src="{!URLFOR($Resource.Library, 'images/prev.png')}" width="13" height="28" />
                                                <apex:actionSupport event="onclick" action="{!goprev}" rerender="wcTopBar" />   
                                              </a>
                                        </div>
______________________________________________________________________

 

public class calendarController{

  public List<dayInfo> daysOfWeek {get;set;}

   Date pw;

 public calendarController(){
        daysOfWeek = new List<dayInfo>();
        pw = system.Today().toStartOfWeek();
        daysOfWeek = calUtil.buildDaysOfWeek(pw);
}

public PageReference goprev(){
        pw = system.Today().toStartOfWeek().addDays(-7);
        daysOfWeek = calUtil.buildDaysOfWeek(pw);
        return null;
    }

 

public PageReference goprev(){
        pw = system.Today().toStartOfWeek().addDays(-7);
        daysOfWeek = calUtil.buildDaysOfWeek(pw);
        return null;
    }
__________________________________________________________

Hi,

 

I'd like to make a trigger that would delete a lead record when the lead first name and last name are the same.  Here is what I have so far and I'm getting error message:

 

Apex trigger Test1 caused an unexpected exception, contact your administrator: Test1: execution of BeforeInsert caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.Test1: line 5, column 6

 

What do I need to change?

 

trigger Test1 on Lead (before insert) {
   for(Lead a: Trigger.new){
 if (a.firstname == a.lastname)
 try {
     delete a;
   } catch (DmlException e)
   {}
   }
  }

 

Thanks in advance!

  • April 19, 2011
  • Like
  • 0