• renuami
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 39
    Replies

Folks

 

Hope someone can help me get my first backbone app working

 

below is the snippet of code that i have written in visualforce using backbone . unfortunately i dont see the output when i access te VF page. But for the same code i see the out put when i run it using regular html.

 

 Hello World text should be displayed when i run this. but no idea whats wrong with this code.

 

can someone advise?

 

<apex:page standardStylesheets="false" applyBodyTag="false" contentType="text/html" controller="ParsingJSON">
 
 <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>

   <script  type="text/javascript">
  
    ListView = Backbone.Force.View.extend(
 
        {
 
            //el: $('body'),
 
            initialize: function( x )
 
            {
                //alert('My first Backbone');
                _.bindAll(this, 'render');
 
                this.render( x );
 
            },
 
            render: function( x )
 
            {
 
               //alert('My first Backbone');
 
                x.append("<ul> <li>hello world</li> </ul>");
 
                //el.append("<ul> <li>hello world</li> </ul>");
 
            }
 
        });
 
        var listView = new ListView($('#temp'));

    </script>
    </head>
 <body>
<div id="temp" style="color:#0000FF">
  <h3>This is a heading</h3>
  <p>This is a paragraph.</p>
</div>
 </body>
 
</apex:page>

 

Hello

 

Can someone please give me some idea on how to achieve the below?

 

I have a lookUp to user Object. On selecting a value in the user look up i would like the Address information of the selected user  to be populated in the inputfields.

 

 

<apex:Page Controller="test_controller">
<apex:form>
<apex:PageBlock> 
<apex:inputField value="{!aw.User__c}"  />
<apex:inputField value="{!aw.Street__c}"  />
<apex:inputField value="{!aw.City__c}"  />
<apex:inputField value="{!aw.State__c}"  />
<apex:inputField value="{!aw.Country__c}"  />
<apex:inputField value="{!aw.Zip_code__c}"  />

<apex:pageblockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"
</apex:pageblockbuttons>
</apex:PageBlock> </apex:form> </apex:page> public class test_controller { public Travel__c aw {get; set;} public test_controller() { aw = new Travel__c(); }
public PageReference save()
    {
        return null;
    }
}

 

 

Hi

 

Is there an option to query user login history in Apex? If so can someone please provide an example or any documentation?

 

 

Thanks

Hi -

 

Travel__c custom Object is the related list under Opportunity. When i try to grab the AccountId from Opportunity using child relationship the value is coming as null. When i query the same in Apex explorer i am getting the results.

 

Please advise what is wrong here?

 

 

trigger test_sample on Travel__c (after update,after insert) 
{
    if(trigger.isAfter)
    {
        if(trigger.isUpdate)        
{ for(Travel__c t:Trigger.new) { system.debug('Opportunity AccountId Value '+t.Opportunity__r.Account.Id); } } } }

 

 

 

Hi

 

If i do not select any color the value of colr is null. when Submit button is clicked for the code below just the outputText value should be displayed.

 

But a new window is openening and the same test1 page is appearing with the outPuttext in the new Window.

 

 If the color value is null or empty then the new window should not be opened. How can we restrict this?

 

Please advise.Thanks

 

 

<apex:page controller="test1">
<apex:form >
<apex:pageBlock>
<apex:outputText value="please select color" rendered="{!err}"/>
<apex:outputLabel value="Select color" />
<apex:selectRadio value="{!colr}">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio>
<apex:CommandLink action="{!myaction}" target="_blank">Submit</apex:CommandLink>
</apex:PageBlock> </form> </page> public class test1 { public String colr{get;set;} Public Boolean err=false; public Boolean geterr(){ return err;} public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('Red','Red')); options.add(new SelectOption('Blue','Blue')); return options; } public PageReference myaction() { if(colr == null || colr == '') { err=true; return null; } else { PageReference pr = new PageReference('/apex/test2'); return pr; } } }

 

 

 

Hi -

 

I know i am doing something wrong with in redendering, i am unable to figure out the issue can someone please help?..thanks

 

We have 4  AirLineItems

 

  - United

  - US Airways

  - Delta

  - Jet Blue

 

 

when Jet Blue is selected, then under DestinationColumn we do not want to show/render the  inputfield for that particular row. For all other selections DestinationColumn/rows should be rendered.

 

I tried the following two but no luck...

 

 rendered="{t.airlinesSelection <> 'Jet Blue'}"

 rendered="{t.airlinesSelection != 'Jet Blue'}" 

 

Please advise....

 

My page

 

<apex:page controller="Travel_Details">
<apex:form>
<apex:pageBlock >
<apex:pageBlockTable value="{!travels}" var="t" id="travelTable">

<apex:column headervalue="AirLines" id="Aircolumn">
<apex:selectList value="{!t.airlinesSelection}">
<apex:selectOptions value="{!AirLineItems}"/>
<apex:actionSupport event="onchange" rerender="travelTable"/>
</apex:selectList>
</apex:column>

<apex:column headervalue="Detail" id="Destinationcolumn">
<apex:inputField value="{!t.ct.AccountId}" rendered="{t.airlinesSelection!='Jet Blue'}" />
</apex:column>

</apex:pageBlockTable>
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Message Edited by renuami on 03-26-2010 10:10 AM
Message Edited by renuami on 03-26-2010 10:20 AM

i have some complex requirement...any help on this is much appriciated!!! thanks..

 

I tried something but not able to get it work...events are not firing...

 

My requirement is, when Web is selected in the Source dropdown then for that row, In the Detail Info column, detail info dropdown should be displayed/enabled. (for all other rows the detail info dropdown should be disabled/hide).

 

if again in the second row, when web is selected in the Source dropdown then again for that row detail info dropdown should be displayed, else it should be disabled or hidden.

 

I have written some thing in OnSelect but it is not firing

 

 

<apex:page controller="controller_test" action="{!init1}">
<apex:form >
<apex:PageBlock>
<apex:pageBlockTable value="{!Event_Results}" var="eve" id="TheTable">
<apex:column headervalue="Source">
<apex:selectList value="{!source_info}" required="true" multiselect="false" size="1" onSelect="RRTheTable">
<apex:selectOptions value="{!Source_Items}"/>
</apex:selectList>
</apex:column>
<apex:column headervalue="Detail Info">
<apex:selectList value="{!Detail_Name}" required="true" multiselect="false" size="1" rendered="{!source_info=='Web'}" >
<apex:selectOptions value="{!Detail_Items}" rendered="{!source_info=='Web'}"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>

 

 

<apex:actionFunction name="RRTheTable" action="{!Refresh}" rerender="TheTable"/>


<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

 

 

public with sharing class controller_test
{
List<Event> events_info = new List<Event>();
List<String> WhoIds = new List<String>();
List<Contact> Contacts_info = new List<Contact>();

public String source_info,detail_Name;

public String getSource_info()
{
return source_info;
}

public void setSource_info(String source_info)
{
this.source_info= source_info;
}

public String getDetail_Name()
{
return detail_Name;
}

public void setDetail_Name(String detail_Name)
{
this.detail_Name= detail_Name;
}

public List<SelectOption> getSource_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Web','Web'));
options3.add(new SelectOption('Email','Email'));
options3.add(new SelectOption('Phone','Phone'));
return options3;
}

public List<SelectOption> getDetail_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Google','Google'));
options3.add(new SelectOption('Yahoo','Yahoo'));
options3.add(new SelectOption('rediff','rediff'));
return options3;
}


public PageReference init1()
{
events_info=[Select Id,AccountId,What.Name,Who.Name,Who.Email,Who.Id from Event Where OwnerId = :UserInfo.getUserId() and order by Whoid limit 3];
for(Integer i=0;i<events_info.size();i++)
{
WhoIds.add(events_info[i].Who.Id);
}
for(Contact c:[Select Id,Email,Accountid from Contact where Id IN:WhoIds order by Id])
{
Contacts_info.add(c);
}

return null;
}

Public List<Event> getEvent_Results()
{
return events_info;
}

Public List<Contact> getContact_Results()
{
return Contacts_info;
}

public PageReference save()
{
return null;
}

public PageReference Refresh()
{
return null;
}

}

 

 

 

 

Message Edited by renuami on 03-05-2010 05:51 AM
Message Edited by renuami on 03-05-2010 06:41 AM

Can someone please assist me with this?

 

We are displaying inpufield in the pageblocktable.

when the form is saved, how can we pass the inputfield value for each row in the pagblocktable to the controller?

 

 

 

 

<apex:page controller="controller_test"> <apex:form>

<apex:pageblock>

<apex:pageBlockTable value="{!Contact_Results}" var="eve"> <apex:column> <apex:inputField value="{!eve.Email}" required="true"></apex:inputField> </apex:column> </apex:pageblocktable>

<apex:pageblockButtons>

<apex:commandButton action="{!save}" value="Save">

</apex:pageBlockButtons>
</apex:pageBlock>

</apex:form> </apex:page> public class controller_test { List<Contact> Contacts_info = new List<Contact>(); for(Contact c:[Select Id,Email from Contact where Id IN:WhoIds]) { Contacts_info.add(c); } } Public List<Contact> getContact_Results() { return Contacts_info; } }

 

 

 

 

 Hello -

 

My trigger below is causing error during Mass updates 

 

Error:System Exception:Too Many Soql Queries: 21

 

Can someone please guide me how to resolve this error.

 

Thanks in advance

 

trigger Opportunity_Trigger on Opportunity (before insert, before update)
{
for(Opportunity opp : Trigger.new)
{
if(opp.RecordTypeId == '0123000000002GxAAI' || opp.RecordTypeId=='012400000000kcUAAQ')
{
oppList.add(opp);
}
}

if(oppList.size() > 0)
{
Opportunity_Class.Manager_Update(oppList);
}
}

 

 

 

 

 

 

 

public class Opportunity_Class
{

public static void Manager_Update(Opportunity[] opp)
{
for(Opportunity op1: opp)
{
for(User u: [Select mng_name__c from User where Id=:op1.OwnerId])
{
op1.Manager_Name__c=u.mng_name__c;
}
}
}

}

 

 

 

Message Edited by renuami on 11-05-2009 08:52 AM

on Case Object i have a custom field case_assigned_to__c (LOOKUP) to user.

 

  FieldName is Case_Assigned_to

  API Name  is Case_Assigned_to__c

 Child Relationship Name is AssignedTo

 

When i query

 

 

(Select Id,Contact.Name,Subject,ClosedDate,Owner.Name,Case_Assigned_to__c.Name from case limit 10)

I am receving this error Didn't understand relationship 'Case_Assigned_to__c' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.

 
I also tried AssignedTo__r.Name

 

Please advise....How to grab the user name ?

 

 

 

 

Hi -

 

Is there anyway to hide the custon list button from certain users?

 

We created a custom list button on contacts and we need this list button only visible on one list view. (since this cannot be done). Is there any way to make it not visible to certain users

 

Please Advise

Message Edited by renuami on 10-02-2009 07:55 AM

My requirement is to automatically close VF Page after clicking the save command button.

 

 

<script>
function closeRefresh()
{
top.parent.window.opener.location.href = "/003/o";
top.parent.window.close();
}
</script>

<apex:commandButton value="save" action="{!save1}" onclick="javascript&colon;closeRefresh();"/>

 

 

 

I am clicking on the link on the List view section of the consoleconsole. VF Pages open which have a save button. Which when clicked updates some values on the contact Object and should close this opened VF Page.

 

I am trying this with as shown above but not able to get it to work. Please advise!!!Thanks..

 

 

Message Edited by renuami on 08-19-2009 01:18 PM

Hello

 

My requirement is to  displayed a table with two chexbox columns and allow the user to select only one checkbox in each column.

 

The below code is working fine for only one column. first when i select first checkbox in mastercolumn and then select 2nd checkbox in the same mastercolumn then it is automatically deselecting the first and selecting the 2nd using the below code.

 

But when i select any checkbox in the duplicatecolumn then the checkbox selected in the mastercolumn is getting deselected.

 

Does anyone have any idea on how to resolve this issue?..please advise.....Thanks in advance

 

 

   Master

    Duplicate

         Name

          Owner

              

                 

         Acme1

           john

              

                 

         Acme2

           jim

              

                 

          Acme

           john

 

<apex:page tabStyle="Account" controller="Account_controller" action="{!init}">
<script>
var selectedChkbox;
function deSelectOthers(chkBox)
{
if (chkBox.checked)
{
if ((chkBox != selectedChkbox) && (selectedChkbox != null))
{
selectedChkbox.checked = false;
}
selectedChkbox = chkBox;
}
}
</script>
<apex:form >

<apex:pageBlock>
<apex:panelGrid id="AccountDetail" columns="1" width="150%">
<apex:pageBlock id="page1">
<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!continue1}" value="Continue"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Select Master and Dupe records">
<apex:pageBlockTable value="{!AccountResults}" var="acc" rules="all" width="150%">
<apex:column headerValue="Master">
<apex:outputPanel id="op1">
<apex:inputCheckBox value="{!Mstchk}" id="master_Checkbox" disabled="{!Mstchk}" onclick="deSelectOthers(this)">
</apex:inputCheckBox>
</apex:outputPanel>
<script>
if ("{!Mstchk}" == "true")
{
var idForSelectedBox = "$component.master_Checkbox";
selectedChkbox = document.getElementById(idForSelectedBox);
}

</script>
</apex:column>

<apex:column headerValue="Duplicate">
<apex:outputPanel id="op2">
<apex:inputCheckBox value="{!Dupchk}" id="duplicate_Checkbox" disabled="{!Dupchk}" onclick="deSelectOthers(this)">
</apex:inputCheckBox>
</apex:outputPanel>
<script>
if ("{!Dupchk}" == "true")
{
var idForSelectedBox = "$component.duplicate_Checkbox";
selectedChkbox = document.getElementById(idForSelectedBox);
}
</script>

</apex:column>

<apex:column headerValue="Name" value="{!acc.Name}">
</apex:column>
<apex:column headerValue="Owner" value="{!acc.Owner.Name}">
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:panelGrid>
</apex:form>
</apex:page>

 

 

public class Account_controller

{
private String searchText;
private Boolean Dupchk;
private Boolean Mstchk;
public string AName;
Id AcctId =ApexPages.currentPage().getparameters().get('id');
public Account acctName;
List<Account> AccountResults=null;

public List<Account> getAccountResults()
{
return AccountResults;
}

public Boolean getDupChk()
{
return Dupchk;
}
public void setDupChk (Boolean Dupchk)
{
this.Dupchk = Dupchk;

}

public Boolean getMstChk()
{
return Mstchk;
}
public void setMstChk (Boolean Mstchk)
{
this.Mstchk = Mstchk;

}


public string getSearchText()
{
return AName;
}
public void setSearchText (String searchText)
{
this.searchText = searchText;
}

public PageReference continue1()
{
return null;
}

public PageReference init()
{
acctName=[Select Name from Account where id=:AcctId];
AName=acctName.Name;
return null;
}

public void search()
{
try
{
AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: searchText+'%'];

}
catch (Exception e)
{
AccountResults = (List<Account>)null;
System.Debug('Error in search criteria.');
}
}

public Class AccountResults
{
public Account Acc
{
get;
set;
}
public Boolean selected
{
get;
set;
}
public AccountResults(Account a)
{
Acc=a;
selected=false;
}
}
}

 


 

Message Edited by renuami on 07-17-2009 11:32 AM

Hello

 

can anyone please throw some ideas..on how to solve the below issue ....many thanks in advance

 

My requirement is to display a text box with Account Name prefilled in it. And also users can edit the text in that texbox.

 

When search button is clicked, the text in the textbox should be passed to the controller to get the records.

 

How can i pass the textbox value to the controller.

 

i know we should pass the values like this...

 

<apex:inputText id="AcName" value="{!searchText}"/>

 

 but since i need to prefilled with the Account name,  i cannot go with the above way...please advise...

 

<apex:page tabStyle="Account" controller="Account_controller" action="{!init}">

<apex:form>
<apex:pageBlock title="Account Delete">
<apex:pageBlockSection title="Account Search">
<apex:pageBlockSectionItem >
<apex:panelGroup >
<apex:outputLabel for="AcName">Account Name:&nbsp; </apex:outputLabel>
<apex:inputText id="AcName" value="{!AccountName.Name}"/>
<apex:commandButton id="Search1" value=" Search " action="{!search}" reRender="AccountDetail" accesskey="\r\n"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>

 

 

public class Account_controller

{
private String searchText;
public Account acctName;
Id AcctId = ApexPages.currentPage().getparameters().get('id');
public Account getAccountName()
{
return acctName;
}
public string getSearchText()
{
return searchText;
}
public void setSearchText (String searchText)
{
this.searchText = searchText;
}

List<Account> AccountResults=null;
public List<Account> getAccountResults()
{
return AccountResults;
}

public PageReference init()
{
acctName=[Select Name from Account where id=:AcctId];
return null;
}
public void search()
{
try
{
// Account acName=[Select Name from Account where id=:AcctId];
// AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: acName.Name+'%'];

 

AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: searchText+'%'];

}
catch (Exception e)
{
AccountResults = (List<Account>)null;
System.Debug('Error in search criteria.');
}
}

}

 

Trigger Newbie question

 

The below scenario is working for one record...Please Advise for mass updates scenario.

 

What i am trying to accomplish is,Under Standard Account Object,  Travel is the Custom Object. Intl_Travel_account__c is the look up for Account in Travel Custom Object.

 

For one Account there can be more than 1 Travel records.

Below logic is written for AfterInsert method. But this is working for only one record.

 

There will be scenarios where  Intl_Travel_account__c field on travel Object will be updated with some other Account value via data loader. Below will be the information i will be updating via data loader.

 

When updating, the code should check to see if there are any Travel records with status__c=true under that Account,  if there are any then Intl_Travelled__c field on Account should be Updated.

 

Travel__c.id

Intl_travelAccount__c

0001

ABC1

0002

ABC2

0003

ABC3

0004

ABC4

 

 

 

 The issue with the below code is, for all the Travel records, Intl_Travel_Account__cfield is updating with the last value (ABC4) in the CSV file above.

public static void AfterInsertMethod(Travel[] tt) { List<Account> TravelAcctList = new List<Account>(); Account travelAcct; for( Travel__c t: tt) { travelAcct =new Account(Id=t.Intl_Travel_account__c); } Integer tcount=[select count() from Travel__c where Intl_Travel_account__c=:travelAcct.Id and t.status__c=true limit 10]; if(tcount>0) { travelAcct.Intl_Travelled__c='Travelled'; } else { travelAcct.Intl_Travelled__c=''; } TravelAcctList.add(travelAcct); update TravelAcctList ; }

 

 Please advise...Thanks in advance

renuamisha

 

Hello

 

I am trying to update the Account field.

 

Initially i was getting system.list exception duplicate id in list error . When looked at the debug log it looks like there are duplicate Account ids. 

 

So what i am planning to do is first checkwhether Account id is already present in the list, if it is present do not add it again to the list. When comparing the Account id with the values in the list i am ending up with the error

Comparison arguments must be compatible types: Id, SOBJECT:Account 

 

 please help in solving this issue !!!

 

public static void BeforeInsertMethod(Travel__c [] tt)

{
 

List<Account> TravelAcctList = new List<Account>();

for( Travel__c t: tt)
{

TravelAccount Acct;
TravelAcct=new Account(Id = t.Travel_account__c);
if(t.Status__c==true)
{
t.Confirm__c=true;
TravelAcct.Send_Confirmation__c = 'OK';
Integer List_count=TravelAcctList.size();
for(Integer i=0;i<=List_count;i++)
{
//getting error here//if(TravelAcct.Id==TravelAcctList.get(i))
{
}
else
{
TravelAcctList.add ( TravelAcct );
}
}
}
else
{

}
}

}

 

Hi

Finally learned how to write test methods. But it looks like the code coverage is not enough. I got 55% code coverage. Please giude me how to cover the rest.

When i run the tests i got the following lines are not covered. I am not getting any idea of how to write. please guide...thanks

 

Code Not Covered

 

Class

Travelling_Redirect

10

16

 

Class

Travelling_Redirect

12

21

 

Class

Travelling_Redirect

13

16

 

Class

Travelling_Redirect

14

21

 

Class

Travelling_Redirect

15

16

 

Class

Travelling_Redirect

16

21

 

Class

Travelling_Redirect

17

16

 

Class

Travelling_Redirect

19

16

 

Class

Travelling_Redirect

31

21

 

Class

Travelling_Redirect

33

25

 

Class

Travelling_Redirect

35

21

 

Class

Travelling_Redirect

36

21

 

Class

Travelling_Redirect

38

21

 

 

public class Travelling_Redirect
{
DateTime t;
List<Travelling__c> tvt;

public PageReference init()
{
User us=[Select TIMEZONESIDKEY from User where id=:UserInfo.getUserId()];
{
if(us.TIMEZONESIDKEY=='America/New_York' || us.TIMEZONESIDKEY=='America/Panama')
t=System.Now();
else if(us.TIMEZONESIDKEY=='America/Chicago' || us.TIMEZONESIDKEY=='America/El_Salvador')
t=System.Now()+1;
else if(us.TIMEZONESIDKEY=='America/Denver' || us.TIMEZONESIDKEY=='America/Phoenix')
t=System.Now()+2;
else if(us.TIMEZONESIDKEY=='America/Los_Angeles' || us.TIMEZONESIDKEY=='America/Tijuana')
t=System.Now()+3;
else
t=System.Now();
}
tvt=[select place, redemption_date__c from Travelling__c where expiration_date__c>=:t and SFDC_ID__c=:UserInfo.getUserId() limit 1];
Integer count= tvt.size();
return redirectTest(count,tvt);
}
public PageReference redirectTest(Integer count,List<Travelling__c> tvt)
{
PageReference myPR = null;
DateTime resu;
if(tvt.size()>0)
{
for(Travelling__c t:tvt)
{
resu=t. redemption_date__c;
}
if(resu==null)
myPR=Page.Travelling_Home;
else
myPR=Page. Travelling _AlreadySelected;
}
else
myPR = Page.Travelling_No_Places;

if (myPR != null)
myPR.setRedirect(true);
return myPR;
}


public static testMethod void results()
{
Travelling_Redirect test=new Travelling_Redirect();
test.init();
}
}

 

 

 

Message Edited by renuami on 04-15-2009 12:05 PM

Hello

 

can someone help me how to display only the date value

 

 expiration_date__c field is defined as datetime. so it is displaying the value as Sun May 31 19:00:00 GMT 2009.

 

But i want to display the  expiration_date__c value as 5/31/2009

 

 

 

<apex:page controller="Travelling_Home" action="{!init}"> <apex:form > Your expiration date is {!tvtresults.expiration_date__c} </apex:form> </apex:page>

 

 

public class Travelling_Home { Travelling__c tvt; public Travelling__c gettvtresults() { return tvt; } public PageReference init() { if(tvt==null) tvt=[select place__c,expiration_date__c from Travelling__c__c where expiration_date__c>=TODAY and USER_ID__c=:UserInfo.getUserId() limit 1]; return null;

} }

 

 

Hi friends

someone please help me to resolve the following.

Data is stored in the object Travelling__c as,

 

Place

userid

Lasvegas

0001

Florida

0001

California

0001

Florida

0001

Lasvegas

0001

 

trying to display the the total trips for the user ooo1. In the below format

 

Trips

Place

2

Lasvegas

2

Florida

1

California

 

  Basically here Trips is the count of the trips to each place the User has Travelled.

 

 

Here is my VF Page and controller. I am able to display the results for places. I need some help on how to display the Trips Value... Please help..

 

<apex:page controller="TravellingSummary" >
<apex:form >
<apex:pageBlock><br />
<font face="Arial" size="3"><b> Below summarizes your Total Trips:</b></font><br /><br /><br />
<apex:pageBlockTable value="{!Summary}" var="summ">
<!-- <apex:column headervalue="Trips">
<apex:outputtext value="1"></apex:outputtext>

</apex:Column> -->
<apex:column headervalue="Place">
<apex:outputtext value="{!summ.place__c}"></apex:outputtext>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons location="Bottom" >
<apex:commandButton action="{!save}" value="Submit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>

</apex:pageBlock>
</apex:form>

</apex:page>

public class TravellingSummary
{
public List<Travelling__c> tve;
public PageReference cancel() {
return null;
}
public PageReference save() {
return null;
}

public List<Travelling__c> getSummary()
{
tve=[Select Place from Travelling__c where user_ID__c=:UserInfo.getUserId()];
return tve;
}

}

 

 

 

 

 

Hi friends -

 

Newbie question.. help please? any of you have the following situation?

 

When user clicks on the custom link on the home page, depending on the count value the user should be redirected to either page ABC1 or ABC2.

 

I mean if the count value=0 redirect the page to ABC1 other wise redirect to ABC2

 

I am trying to achieve this using custom comtroller.

 

public class MyController

{

List<CustomObject__c > co;

public List<CustomObject__c > getPageName()

{

 co=[Select values from CustomObject__c];

Integer count=co.size();

 

//Please help how to proceed with this part..

if(count ==0)

{

redirect to page ABC1;

}

else

{

redirect to page ABC2;

}

}

}

Folks

 

Hope someone can help me get my first backbone app working

 

below is the snippet of code that i have written in visualforce using backbone . unfortunately i dont see the output when i access te VF page. But for the same code i see the out put when i run it using regular html.

 

 Hello World text should be displayed when i run this. but no idea whats wrong with this code.

 

can someone advise?

 

<apex:page standardStylesheets="false" applyBodyTag="false" contentType="text/html" controller="ParsingJSON">
 
 <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js"></script>

   <script  type="text/javascript">
  
    ListView = Backbone.Force.View.extend(
 
        {
 
            //el: $('body'),
 
            initialize: function( x )
 
            {
                //alert('My first Backbone');
                _.bindAll(this, 'render');
 
                this.render( x );
 
            },
 
            render: function( x )
 
            {
 
               //alert('My first Backbone');
 
                x.append("<ul> <li>hello world</li> </ul>");
 
                //el.append("<ul> <li>hello world</li> </ul>");
 
            }
 
        });
 
        var listView = new ListView($('#temp'));

    </script>
    </head>
 <body>
<div id="temp" style="color:#0000FF">
  <h3>This is a heading</h3>
  <p>This is a paragraph.</p>
</div>
 </body>
 
</apex:page>

 

Hello

 

Can someone please give me some idea on how to achieve the below?

 

I have a lookUp to user Object. On selecting a value in the user look up i would like the Address information of the selected user  to be populated in the inputfields.

 

 

<apex:Page Controller="test_controller">
<apex:form>
<apex:PageBlock> 
<apex:inputField value="{!aw.User__c}"  />
<apex:inputField value="{!aw.Street__c}"  />
<apex:inputField value="{!aw.City__c}"  />
<apex:inputField value="{!aw.State__c}"  />
<apex:inputField value="{!aw.Country__c}"  />
<apex:inputField value="{!aw.Zip_code__c}"  />

<apex:pageblockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"
</apex:pageblockbuttons>
</apex:PageBlock> </apex:form> </apex:page> public class test_controller { public Travel__c aw {get; set;} public test_controller() { aw = new Travel__c(); }
public PageReference save()
    {
        return null;
    }
}

 

 

Hi -

 

Travel__c custom Object is the related list under Opportunity. When i try to grab the AccountId from Opportunity using child relationship the value is coming as null. When i query the same in Apex explorer i am getting the results.

 

Please advise what is wrong here?

 

 

trigger test_sample on Travel__c (after update,after insert) 
{
    if(trigger.isAfter)
    {
        if(trigger.isUpdate)        
{ for(Travel__c t:Trigger.new) { system.debug('Opportunity AccountId Value '+t.Opportunity__r.Account.Id); } } } }

 

 

 

Hi

 

If i do not select any color the value of colr is null. when Submit button is clicked for the code below just the outputText value should be displayed.

 

But a new window is openening and the same test1 page is appearing with the outPuttext in the new Window.

 

 If the color value is null or empty then the new window should not be opened. How can we restrict this?

 

Please advise.Thanks

 

 

<apex:page controller="test1">
<apex:form >
<apex:pageBlock>
<apex:outputText value="please select color" rendered="{!err}"/>
<apex:outputLabel value="Select color" />
<apex:selectRadio value="{!colr}">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio>
<apex:CommandLink action="{!myaction}" target="_blank">Submit</apex:CommandLink>
</apex:PageBlock> </form> </page> public class test1 { public String colr{get;set;} Public Boolean err=false; public Boolean geterr(){ return err;} public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('Red','Red')); options.add(new SelectOption('Blue','Blue')); return options; } public PageReference myaction() { if(colr == null || colr == '') { err=true; return null; } else { PageReference pr = new PageReference('/apex/test2'); return pr; } } }

 

 

 

Hi -

 

I know i am doing something wrong with in redendering, i am unable to figure out the issue can someone please help?..thanks

 

We have 4  AirLineItems

 

  - United

  - US Airways

  - Delta

  - Jet Blue

 

 

when Jet Blue is selected, then under DestinationColumn we do not want to show/render the  inputfield for that particular row. For all other selections DestinationColumn/rows should be rendered.

 

I tried the following two but no luck...

 

 rendered="{t.airlinesSelection <> 'Jet Blue'}"

 rendered="{t.airlinesSelection != 'Jet Blue'}" 

 

Please advise....

 

My page

 

<apex:page controller="Travel_Details">
<apex:form>
<apex:pageBlock >
<apex:pageBlockTable value="{!travels}" var="t" id="travelTable">

<apex:column headervalue="AirLines" id="Aircolumn">
<apex:selectList value="{!t.airlinesSelection}">
<apex:selectOptions value="{!AirLineItems}"/>
<apex:actionSupport event="onchange" rerender="travelTable"/>
</apex:selectList>
</apex:column>

<apex:column headervalue="Detail" id="Destinationcolumn">
<apex:inputField value="{!t.ct.AccountId}" rendered="{t.airlinesSelection!='Jet Blue'}" />
</apex:column>

</apex:pageBlockTable>
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Message Edited by renuami on 03-26-2010 10:10 AM
Message Edited by renuami on 03-26-2010 10:20 AM

i have some complex requirement...any help on this is much appriciated!!! thanks..

 

I tried something but not able to get it work...events are not firing...

 

My requirement is, when Web is selected in the Source dropdown then for that row, In the Detail Info column, detail info dropdown should be displayed/enabled. (for all other rows the detail info dropdown should be disabled/hide).

 

if again in the second row, when web is selected in the Source dropdown then again for that row detail info dropdown should be displayed, else it should be disabled or hidden.

 

I have written some thing in OnSelect but it is not firing

 

 

<apex:page controller="controller_test" action="{!init1}">
<apex:form >
<apex:PageBlock>
<apex:pageBlockTable value="{!Event_Results}" var="eve" id="TheTable">
<apex:column headervalue="Source">
<apex:selectList value="{!source_info}" required="true" multiselect="false" size="1" onSelect="RRTheTable">
<apex:selectOptions value="{!Source_Items}"/>
</apex:selectList>
</apex:column>
<apex:column headervalue="Detail Info">
<apex:selectList value="{!Detail_Name}" required="true" multiselect="false" size="1" rendered="{!source_info=='Web'}" >
<apex:selectOptions value="{!Detail_Items}" rendered="{!source_info=='Web'}"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>

 

 

<apex:actionFunction name="RRTheTable" action="{!Refresh}" rerender="TheTable"/>


<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

 

 

public with sharing class controller_test
{
List<Event> events_info = new List<Event>();
List<String> WhoIds = new List<String>();
List<Contact> Contacts_info = new List<Contact>();

public String source_info,detail_Name;

public String getSource_info()
{
return source_info;
}

public void setSource_info(String source_info)
{
this.source_info= source_info;
}

public String getDetail_Name()
{
return detail_Name;
}

public void setDetail_Name(String detail_Name)
{
this.detail_Name= detail_Name;
}

public List<SelectOption> getSource_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Web','Web'));
options3.add(new SelectOption('Email','Email'));
options3.add(new SelectOption('Phone','Phone'));
return options3;
}

public List<SelectOption> getDetail_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Google','Google'));
options3.add(new SelectOption('Yahoo','Yahoo'));
options3.add(new SelectOption('rediff','rediff'));
return options3;
}


public PageReference init1()
{
events_info=[Select Id,AccountId,What.Name,Who.Name,Who.Email,Who.Id from Event Where OwnerId = :UserInfo.getUserId() and order by Whoid limit 3];
for(Integer i=0;i<events_info.size();i++)
{
WhoIds.add(events_info[i].Who.Id);
}
for(Contact c:[Select Id,Email,Accountid from Contact where Id IN:WhoIds order by Id])
{
Contacts_info.add(c);
}

return null;
}

Public List<Event> getEvent_Results()
{
return events_info;
}

Public List<Contact> getContact_Results()
{
return Contacts_info;
}

public PageReference save()
{
return null;
}

public PageReference Refresh()
{
return null;
}

}

 

 

 

 

Message Edited by renuami on 03-05-2010 05:51 AM
Message Edited by renuami on 03-05-2010 06:41 AM

Can someone please assist me with this?

 

We are displaying inpufield in the pageblocktable.

when the form is saved, how can we pass the inputfield value for each row in the pagblocktable to the controller?

 

 

 

 

<apex:page controller="controller_test"> <apex:form>

<apex:pageblock>

<apex:pageBlockTable value="{!Contact_Results}" var="eve"> <apex:column> <apex:inputField value="{!eve.Email}" required="true"></apex:inputField> </apex:column> </apex:pageblocktable>

<apex:pageblockButtons>

<apex:commandButton action="{!save}" value="Save">

</apex:pageBlockButtons>
</apex:pageBlock>

</apex:form> </apex:page> public class controller_test { List<Contact> Contacts_info = new List<Contact>(); for(Contact c:[Select Id,Email from Contact where Id IN:WhoIds]) { Contacts_info.add(c); } } Public List<Contact> getContact_Results() { return Contacts_info; } }

 

 

 

My requirement is to automatically close VF Page after clicking the save command button.

 

 

<script>
function closeRefresh()
{
top.parent.window.opener.location.href = "/003/o";
top.parent.window.close();
}
</script>

<apex:commandButton value="save" action="{!save1}" onclick="javascript&colon;closeRefresh();"/>

 

 

 

I am clicking on the link on the List view section of the consoleconsole. VF Pages open which have a save button. Which when clicked updates some values on the contact Object and should close this opened VF Page.

 

I am trying this with as shown above but not able to get it to work. Please advise!!!Thanks..

 

 

Message Edited by renuami on 08-19-2009 01:18 PM

Hello

 

My requirement is to  displayed a table with two chexbox columns and allow the user to select only one checkbox in each column.

 

The below code is working fine for only one column. first when i select first checkbox in mastercolumn and then select 2nd checkbox in the same mastercolumn then it is automatically deselecting the first and selecting the 2nd using the below code.

 

But when i select any checkbox in the duplicatecolumn then the checkbox selected in the mastercolumn is getting deselected.

 

Does anyone have any idea on how to resolve this issue?..please advise.....Thanks in advance

 

 

   Master

    Duplicate

         Name

          Owner

              

                 

         Acme1

           john

              

                 

         Acme2

           jim

              

                 

          Acme

           john

 

<apex:page tabStyle="Account" controller="Account_controller" action="{!init}">
<script>
var selectedChkbox;
function deSelectOthers(chkBox)
{
if (chkBox.checked)
{
if ((chkBox != selectedChkbox) && (selectedChkbox != null))
{
selectedChkbox.checked = false;
}
selectedChkbox = chkBox;
}
}
</script>
<apex:form >

<apex:pageBlock>
<apex:panelGrid id="AccountDetail" columns="1" width="150%">
<apex:pageBlock id="page1">
<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!continue1}" value="Continue"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Select Master and Dupe records">
<apex:pageBlockTable value="{!AccountResults}" var="acc" rules="all" width="150%">
<apex:column headerValue="Master">
<apex:outputPanel id="op1">
<apex:inputCheckBox value="{!Mstchk}" id="master_Checkbox" disabled="{!Mstchk}" onclick="deSelectOthers(this)">
</apex:inputCheckBox>
</apex:outputPanel>
<script>
if ("{!Mstchk}" == "true")
{
var idForSelectedBox = "$component.master_Checkbox";
selectedChkbox = document.getElementById(idForSelectedBox);
}

</script>
</apex:column>

<apex:column headerValue="Duplicate">
<apex:outputPanel id="op2">
<apex:inputCheckBox value="{!Dupchk}" id="duplicate_Checkbox" disabled="{!Dupchk}" onclick="deSelectOthers(this)">
</apex:inputCheckBox>
</apex:outputPanel>
<script>
if ("{!Dupchk}" == "true")
{
var idForSelectedBox = "$component.duplicate_Checkbox";
selectedChkbox = document.getElementById(idForSelectedBox);
}
</script>

</apex:column>

<apex:column headerValue="Name" value="{!acc.Name}">
</apex:column>
<apex:column headerValue="Owner" value="{!acc.Owner.Name}">
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:panelGrid>
</apex:form>
</apex:page>

 

 

public class Account_controller

{
private String searchText;
private Boolean Dupchk;
private Boolean Mstchk;
public string AName;
Id AcctId =ApexPages.currentPage().getparameters().get('id');
public Account acctName;
List<Account> AccountResults=null;

public List<Account> getAccountResults()
{
return AccountResults;
}

public Boolean getDupChk()
{
return Dupchk;
}
public void setDupChk (Boolean Dupchk)
{
this.Dupchk = Dupchk;

}

public Boolean getMstChk()
{
return Mstchk;
}
public void setMstChk (Boolean Mstchk)
{
this.Mstchk = Mstchk;

}


public string getSearchText()
{
return AName;
}
public void setSearchText (String searchText)
{
this.searchText = searchText;
}

public PageReference continue1()
{
return null;
}

public PageReference init()
{
acctName=[Select Name from Account where id=:AcctId];
AName=acctName.Name;
return null;
}

public void search()
{
try
{
AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: searchText+'%'];

}
catch (Exception e)
{
AccountResults = (List<Account>)null;
System.Debug('Error in search criteria.');
}
}

public Class AccountResults
{
public Account Acc
{
get;
set;
}
public Boolean selected
{
get;
set;
}
public AccountResults(Account a)
{
Acc=a;
selected=false;
}
}
}

 


 

Message Edited by renuami on 07-17-2009 11:32 AM

Hello

 

can anyone please throw some ideas..on how to solve the below issue ....many thanks in advance

 

My requirement is to display a text box with Account Name prefilled in it. And also users can edit the text in that texbox.

 

When search button is clicked, the text in the textbox should be passed to the controller to get the records.

 

How can i pass the textbox value to the controller.

 

i know we should pass the values like this...

 

<apex:inputText id="AcName" value="{!searchText}"/>

 

 but since i need to prefilled with the Account name,  i cannot go with the above way...please advise...

 

<apex:page tabStyle="Account" controller="Account_controller" action="{!init}">

<apex:form>
<apex:pageBlock title="Account Delete">
<apex:pageBlockSection title="Account Search">
<apex:pageBlockSectionItem >
<apex:panelGroup >
<apex:outputLabel for="AcName">Account Name:&nbsp; </apex:outputLabel>
<apex:inputText id="AcName" value="{!AccountName.Name}"/>
<apex:commandButton id="Search1" value=" Search " action="{!search}" reRender="AccountDetail" accesskey="\r\n"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>

 

 

public class Account_controller

{
private String searchText;
public Account acctName;
Id AcctId = ApexPages.currentPage().getparameters().get('id');
public Account getAccountName()
{
return acctName;
}
public string getSearchText()
{
return searchText;
}
public void setSearchText (String searchText)
{
this.searchText = searchText;
}

List<Account> AccountResults=null;
public List<Account> getAccountResults()
{
return AccountResults;
}

public PageReference init()
{
acctName=[Select Name from Account where id=:AcctId];
return null;
}
public void search()
{
try
{
// Account acName=[Select Name from Account where id=:AcctId];
// AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: acName.Name+'%'];

 

AccountResults= (List<Account>)[select Id, Name, Type, BillingStreet,Billingcity,BillingState,BillingPostalCode,Owner.Name from Account where Name like: searchText+'%'];

}
catch (Exception e)
{
AccountResults = (List<Account>)null;
System.Debug('Error in search criteria.');
}
}

}

 

Trigger Newbie question

 

The below scenario is working for one record...Please Advise for mass updates scenario.

 

What i am trying to accomplish is,Under Standard Account Object,  Travel is the Custom Object. Intl_Travel_account__c is the look up for Account in Travel Custom Object.

 

For one Account there can be more than 1 Travel records.

Below logic is written for AfterInsert method. But this is working for only one record.

 

There will be scenarios where  Intl_Travel_account__c field on travel Object will be updated with some other Account value via data loader. Below will be the information i will be updating via data loader.

 

When updating, the code should check to see if there are any Travel records with status__c=true under that Account,  if there are any then Intl_Travelled__c field on Account should be Updated.

 

Travel__c.id

Intl_travelAccount__c

0001

ABC1

0002

ABC2

0003

ABC3

0004

ABC4

 

 

 

 The issue with the below code is, for all the Travel records, Intl_Travel_Account__cfield is updating with the last value (ABC4) in the CSV file above.

public static void AfterInsertMethod(Travel[] tt) { List<Account> TravelAcctList = new List<Account>(); Account travelAcct; for( Travel__c t: tt) { travelAcct =new Account(Id=t.Intl_Travel_account__c); } Integer tcount=[select count() from Travel__c where Intl_Travel_account__c=:travelAcct.Id and t.status__c=true limit 10]; if(tcount>0) { travelAcct.Intl_Travelled__c='Travelled'; } else { travelAcct.Intl_Travelled__c=''; } TravelAcctList.add(travelAcct); update TravelAcctList ; }

 

 Please advise...Thanks in advance

renuamisha