• Raj_
  • NEWBIE
  • -1 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 7
    Replies

So I'm I'm writing a test method for some code that queries RecordType.Name on the Opportunity object. I'm able to grab the RecordType ID and assign it to the Opportunity. System.debug shows that the RecordType I query in the test method has an ID and Name as well.

 

For some reason, it's telling me that Opportunity.RecordType.Name is null, even after I've assigned a RecordType to the Opportunity. Anyone know what's going wrong here? Here's the code:

 

RecordType UpsellRT = [SELECT Id,Name FROM RecordType WHERE sObjectType = 'Opportunity' AND Name = 'UpSell' LIMIT 1];

Opportunity OPP = new Opportunity(
	Name = 'Test Opp',
	RecordTypeId = UpsellRT.Id,
	CloseDate = Date.valueOf('2013-01-01'),
	StageName = 'Closed Won');
insert OPP; 

Hi,

 

Below is my code.

 

Anyone help is appreciated.

 

 

<apex:page showheader="false" sidebar="false" action="{!PageLoadinitial}" controller="GTS_officehashEstimate_Controller">

 

 

function openpopup(){

//var check=document.getElementById('j_id0:sitepage_lite:form:j_id106:0:date').innerText ;
//alert(check);

document.getElementById('searchPopUp').style.display="block";
document.getElementById('blackContent').style.display="block";

}

function closewindow(){
alert('test');
//window.opener.focus();
}

function CloseWindow()
{

CloseLightBox();
}

function getsumTotalGBO(id){
var parameter = document.getElementById(id).value;
alert(parameter);
calculateTotalGBO(parameter);
}
function calculateremainingTotalAllocations(){
var arrData = [];
var gbototal = 0;
var admtotal = 0;
var scrtotal =0;

var totalgbosum = 0;
var totaladmsum = 0;
var ATMbyday =0;
var Maxscr =0;
wrapperlistsize = {!myWrappersList.size};


for(var i = 0;i<wrapperlistsize;i++){
var NaNcheck=parseFloat(document.getElementById('gbototal'+i).value);
var NaNadmcheck= parseFloat(document.getElementById('admtotal'+i).value)
var NaNadmscreen= parseFloat(document.getElementById('scrtotal'+i).value)
// GBO
if(isNaN(NaNcheck)!=true){
gbototal = parseFloat(document.getElementById('gbototal'+i).value);

totalgbosum = eval(totalgbosum) + eval(gbototal);
}
//Admission
if(isNaN(NaNadmcheck)!=true){
admtotal = parseFloat(document.getElementById('admtotal'+i).value);

totaladmsum = eval(totaladmsum) + eval(admtotal);

}
if(isNaN(NaNadmcheck)!=true && isNaN(NaNcheck)!=true){
ATMbyday =NaNcheck/NaNadmcheck;

}
if(isNaN(NaNadmscreen)!=true){
arrData.push(NaNadmscreen);
Maxscr= Math.max.apply(Math, arrData);
}

}

document.getElementById('TotalGBOsum').value=totalgbosum;
document.getElementById('TotalAdmissionsum').value=totaladmsum;
document.getElementById('atp').value=ATMbyday;
document.getElementById('Totalmaxscreen').value=Maxscr;

}







</script>
<style>
.black_overlay {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.2;
opacity: .40;
filter: alpha(opacity = 40);
}

.white_content {
display: none;
position: absolute;
top: 25%;
left: 20%;
width: 60%;
height: 60%;
padding: 1%;
//border: 2px solid blue;
background-color: white;
z-index: 1002;
overflow: auto;
}
</style>


<apex:composition template="GTS_SiteTemplate_Lite">
<apex:define name="dataDisplay">
<c:GTS_Navigation_Menus inputDropId="2" showL2Menu="false"/>
<br/>
<apex:form id="form">

<p>
<h1>
<apex:outputlabel value="hash Estimate Comment"></apex:outputlabel>
<!--<apex:commandButton styleClass="alignright Addbutton" immediate="false" Action="{!saveText}" title="Add Record" ></apex:commandButton>-->
<input type="button" class="btn" onclick="return savehashestimatebyday(); return false;" image="{!URLFOR($Resource.GTS_images,'buttons/create_up.png')}"/>

</h1>
<tr>
<td>

</td>

</tr>
<table width="100%" >
<tr>
<th width="140">
Time Period
</th>
<td>
<apex:outputText value="{!TimePeriod}" id="check"/>
<!-- <apex:inputField value="{!gffspd.Play_Date__c}"/>-->
</td>
<th width="140">
Week Ending Date
</th>
<td>
<apex:outputText value="{!Weekend}" id="check1"/>
<!-- <apex:inputField value="{!gffspd.Play_Date__c}"/>-->
</td>
</tr>
</table>
</p>
<br/>
<br></br>
<br></br>

<h2 style="margin:0 0 0 0">
<apex:outputlabel value="Days Reported"></apex:outputlabel>
</h2>
<table width="100%">

<tr>
<th width="140">Time Period Rental Ratio</th>
<td>
<apex:inputfield value="{!gffspd.Time_Period_Rental_Ratio__c}" />
</td>
<p></p>
<th width="140">Currency</th>
<td>
<apex:outputText value="{!strcurrency}"/>
</td>
</tr>

<tr>
<tr></tr>
<tr></tr>
<th>Play Week#</th>

<td>
<apex:outputText value="{!diffrence}"/>
</td>
</tr>
</table>
<br></br>
<br></br>
<apex:actionFunction action="{!Add}" name="Addrow" immediate="flase" reRender="popup"></apex:actionFunction>
<apex:actionFunction action="{!saveText}" name="savehashestimatebyday" immediate="flase" reRender="dummy"></apex:actionFunction>
<apex:actionFunction name="calculateTotalGBO" action="{!caltotalGBO}" rerender="displayresult2">
<apex:param name="GBOvalue" value="" />
</apex:actionFunction>
<div id="blackContent" class="black_overlay"></div>
<div id="searchPopUp" class="white_content">
<script>
function sumtotalgbo(){
var admfor = 0;
var gbofor = 0;

var totalgbosumfor = 0;
var totaladmsumfor = 0;
var ATMbydayfor =0;

wrapperlistsize = {!lstInner.size};


for(var i = 0;i<wrapperlistsize;i++){
var NaNcheckfor=parseFloat(document.getElementById('gbofor'+i).value);
var NaNadmcheckfor= parseFloat(document.getElementById('admfor'+i).value)
// GBO
if(isNaN(NaNcheckfor)!=true){
gbofor = parseFloat(document.getElementById('gbofor'+i).value);

totalgbosumfor = eval(totalgbosumfor) + eval(gbofor);
}
//Admission
if(isNaN(NaNadmcheckfor)!=true){
admfor = parseFloat(document.getElementById('admfor'+i).value);

totaladmsumfor = eval(totaladmsumfor) + eval(admfor);

}
if(isNaN(NaNadmcheckfor)!=true && isNaN(NaNcheckfor)!=true){
ATMbydayfor =NaNcheck/NaNadmcheck;

}

}

document.getElementById('TotalGBOsumfornew').value=totalgbosumfor;
document.getElementById('TotalAdmsumfornew').value=totaladmsumfor;
document.getElementById('atpfor').value=ATMbydayfor;

}





</script>

<apex:outputpanel id="popup">
<h>GBO By Format</h>
<apex:image styleClass="alignright" onclick="CloseWindow();" URL="{!URLFOR($Resource.GTS_images,'icons/x_icon_B1BBC7.png')}" />
<table style="width:100%;" id="GBOtable">
<tr>



<td style="font-weight: bold;">
&nbsp;&nbsp;<!--<apex:commandbutton image="{!URLFOR($Resource.GTS_images,'buttons/create_up.png')}" id="addbutton" onclick="return Addrow(); return false;" /> -->
<input type="button" class="btn" onclick="return Addrow(); return false;" image="{!URLFOR($Resource.GTS_images,'buttons/create_up.png')}"/>
</td>
<td style="font-weight: bold;">
&nbsp;&nbsp;<apex:commandbutton image="{!URLFOR($Resource.GTS_images,'buttons/save_up.png')}" id="savebutton" action="{!Savegboformat}" />
</td>
<td>
<apex:outputText />
</td>
</tr>
</table>

<apex:outputpanel id="displayresult2" >



<table cellspacing="1" class="tablesorter,standardtable" style="margin-top:10px">
<thead>
<tr>
<th Class="leftheading">Format</th>
<th Class="leftheading">Admission</th>
<th Class="leftheading">GBO</th>
<th Class="leftheading">Avg. Ticket Price</th>

</tr>
</thead>
<tbody>
<apex:variable var="rptIndexnew" value="{!-1}" />
<apex:repeat var="wrapper" value="{!lstInner}">
<apex:variable var="rptIndexnew" value="{!rptIndexnew+1}"/>
<apex:outputtext value="{!rptIndexnew}"/>
<tr>
<td>
<apex:inputField value="{!wrapper.gbf.Format__r.name}" id="namefor" ></apex:inputField>
</td>
<td>
<input type="text" value="{!wrapper.gbf.Admission__c}" id="admfor{!rptIndexnew}" />
</td>
<td>
<input type="text" value="{!wrapper.gbf.GBO__c}" id="gbofor{!rptIndexnew}" />
</td>
<td>
<input type="text" value="{!wrapper.gbf.ATP__c}" id="atpfor" readonly="true" style="border: none" />
</td>
<td>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!wrapper.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</td>

</tr>
</apex:repeat>
<tr>

<td colspan="1">
Total
</td>
<td>
<input type = "text" value="" id="TotalGBOsumfornew" readonly="true" style="border: none"/>
</td>
<td>
<input type = "text" value="" id="totaladmsumfornew" readonly="true" style="border: none"/>
</td>
</tr>
</tbody>
</table>
<!-- End of Display area for a Pagination table -->

</apex:outputpanel>

<!-- <input type="button" class="btn" value="Clear All" onclick="clearsearch()" /> -->
</apex:outputpanel>

</div>
<table id="Estimatedata" class="standardtable" style="margin-top:10px">

<tbody>
<tr>
<th width="240" class="leftheading">
Day
</th>
<th width="240" class="leftheading">
Date
</th>

<th width="240" class="leftheading">
GBO
</th>
<th width="240" class="leftheading">
Screens
</th>
<th width="240" class="leftheading">
Admission
</th>
<th width="240" class="leftheading">
ATP
</th>
<th width="240" class="leftheading">
GBO
</th>
<th width="240" class="leftheading">
Screens
</th>
<th width="240" class="leftheading">
Admission
</th>
<th width="240" class="leftheading">
ATP
</th>
<th width="240" class="leftheading">

</th>
</tr>
<apex:outputpanel id="hashestimatebyday">
<apex:variable var="rptIndex" value="{!-1}" />
<apex:repeat var="wrapper" value="{!myWrappersList}">
<apex:variable var="rptIndex" value="{!rptIndex+1}"/>
<!--<apex:outputtext value="{!rptIndex}"/>-->
<tr>
<td>
<apex:outputlabel value="{!wrapper.obj1.Day__c}"></apex:outputlabel>
</td>

<td>
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}" id="date">
<apex:param value="{!wrapper.obj1.Date__c}" /></apex:outputText>
</td>
<td>
<input type="text" value="{!wrapper.obj1.GBO__c}" id="gbototal{!rptIndex}" onchange="calculateremainingTotalAllocations()" />
<a name="theLink" onclick="openpopup(); return false;">GBO By Format</a>
</td>

<td>
<input type="text" value="{!wrapper.obj1.Screens__c}" id="scrtotal{!rptIndex}" onchange="calculateremainingTotalAllocations()"/>
</td>
<td>
<input type="text" value="{!wrapper.obj1.Admission__c}" id="admtotal{!rptIndex}" onchange="calculateremainingTotalAllocations()"/>
</td>
<td>
<input type="text" value="{!wrapper.obj1.ATP_by_Day__c}" id="atp" readonly="true" style="border: none"/>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.GBO__c}" ></apex:outputText>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.Screens__c}" ></apex:outputText>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.Admission__c}" ></apex:outputText>
</td>
<td>
<apex:outputText value="{!wrapper.obj2.ATP__c}" id="atp3" ></apex:outputText>
</td>
<td>
<a name="theLink" onclick="selecttitles('{!$Component.check}','{!$Component.terrid}');">Theatres Reported</a>
</td>


</tr>
</apex:repeat>
</apex:outputpanel>
<tr>

<td colspan="2">
Total
</td>
<td>
<input type = "text" value="" id="TotalGBOsum" readonly="true" style="border: none"/>
</td>
<td>
<input type = "text" value="" id="Totalmaxscreen" readonly="true" style="border: none"/>
</td>
<td>
<input type = "text" value="" id="TotalAdmissionsum" readonly="true" style="border: none"/>
</td>
</tr>
</tbody>

</table>
<br></br>
<br></br>
<h2 style="margin:0 0 0 0">
<apex:outputlabel value="Comment"></apex:outputlabel>
</h2>
<table>
<tr>
<tr></tr>
<tr></tr>

<th width="140">Assesment</th>
<td>
<apex:inputField value="{!gffspd.Assesment__c}" />
</td>
<th width="140">Notes</th>
<td>
<apex:inputText value="{!gffspd.Territory_Comment__c}" />
</td>
</tr>


</table>


<br></br>
<br></br>
<h2 style="margin:0 0 0 0">
<apex:outputlabel value="Proposed Revised GBO Estimate"></apex:outputlabel>
</h2>
<br></br>
<br></br>
<table>
<tr>
<th width="140">Current Estimate</th>
<td>
<apex:outputText value="{!gffspd.Current_Estimate__c} " />
</td>
<th width="140">Proposed Revise GBO Estimate</th>
<td>
<apex:inputText value="{!gffspd.Proposed_Revised_GBO_Estimate__c}" />
</td>
</tr>


</table>
<table id="Estimatedata" class="standardtable" style="margin-top:10px">

<tbody>
<tr>
<th width="240" class="leftheading">
Action
</th>
<th width="240" class="leftheading">
Date
</th>

<th width="240" class="leftheading">
Status
</th>
<th width="240" class="leftheading">
AssignedTo
</th>
<th width="240" class="leftheading">
Actual Approver
</th>
<th width="240" class="leftheading">
Comments
</th>
<th width="240" class="leftheading">
Overall Status
</th>

</tr>
<apex:outputpanel >

<apex:repeat var="wrapper">

<!--<apex:outputtext value="{!rptIndex}"/>-->
<tr>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>
<td>
<apex:outputlabel ></apex:outputlabel>
</td>




</tr>
</apex:repeat>
</apex:outputpanel>

</tbody>

</table>
</apex:form>
</apex:define>
</apex:composition>
</apex:page>

Hi Experts,

 

Im very new to salesforce so when i write the program in salesforce , so when i displaying the records in tabluar format but it showing some error "

Visualforce Error


System.QueryException: List has no rows for assignment to SObject
Class.mySecondController.getAccount: line 5, column 1 "

 

please check my code once ,

 

public class mySecondController {
  public Account getAccount() {
    return [select id, name,
            (select id, firstname, lastname
             from Contacts limit 5)
            from Account 
            where id =:System.currentPageReference().getParameters().get('id')];
  }
  public String getName() {
    return 'My Second Custom Controller';
  }
}

visual force page:

 

<apex:page controller="mySecondController" tabStyle="Account">
   <apex:pageBlock title="Hello {!$User.FirstName}!">
   You belong to the {!account.name} account.
   </apex:pageBlock>
   <apex:pageBlock title="Contacts">
   <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
    <apex:column >
      {!contact.FirstName}
    </apex:column>
    <apex:column >
      {!contact.LastName}
    </apex:column>
   </apex:dataTable>
   </apex:pageBlock>
</apex:page>

 

Hello,

I wrote a trigger and a test class. My own test class passed. However there's an error thrown out from the other test class which has nothing to do with my trigger. Why it happened like that? Below is the error message. Please advise.

 

System.LimitException: Too many SOQL queries: 101

 

Thanks

Paul

 

 

 

  • September 19, 2013
  • Like
  • 0

I have a trigger which inserts record in The public Groups.

 

But when i edit the records a new record is getting inserted(which should not happen).

 

Below is the Trigger:

trigger GroupCreation on IA_Team__c (after insert,after update)
{
Group grp = new Group();
list<Group> gplist=new list<Group>();
for(IA_Team__c ia:trigger.new){
grp.Name = ia.Name;
grp.DeveloperName = ia.Public_Group_Name__c;
gplist.add(grp);
}

insert gplist;

}

 

  • September 12, 2013
  • Like
  • 0