-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
16Questions
-
20Replies
Test Class is not check something in the loop.
I get ID from java script, but test class is not work.
It is not error, but can not check something in the loop. How do I fix it.
Class
Public String OppID = ApexPages.currentPage().getParameters().get('Oppid'); List<Delivery__c> lsttmpDL = new List<Delivery__c>(); public PageReference SaveDelivery(){ if(OppID != null){ //Pass for(Delivery__c DL : Deliverys){ /////////////////////////// Faild this test class not work. Can not check in the loop. Delivery__c tmpDL = New Delivery__c (); tmpDL.Ship_To_Account__c = DL.Ship_To_Account__c; tmpDL.Order_Taking__c = DL.Order_Taking__c ; tmpDL.Order_Reference__c = DL.Order_Reference__c ; tmpDL.Reference__c = DL.Reference__c; tmpDL.Est_Completed__c = DL.Est_Completed__c; tmpDL.PO_No__c = DL.PO_No__c; tmpDL.PO_Date__c = DL.PO_Date__c; tmpDL.Transfer_Date__c = DL.Transfer_Date__c; tmpDL.Discount_Order__c = DL.Discount_Order__c; tmpDL.Discount_Code_1__c = DL.Discount_Code_1__c; tmpDL.Remark__c = DL.Remark__c; lsttmpDL.Add(tmpDL); } insert lsttmpDL ; } }
Test Class
List<Delivery__c > objdelivery = new List<Delivery__c >(); ApexPages.StandardSetController controller = new ApexPages.StandardSetController(objdelivery); DeliveryPages clsTest = new DeliveryPages(controller); Order_Taking__c OT = New Order_Taking__c(); OT.Periods_of_Order__c = 4; insert OT; ApexPages.currentPage().getParameters().put('OppID', OT.Id); Delivery__c DL = New Delivery__c(); DL.Salesman_Code__c = '12344576'; DL.Order_Taking__c = OT.id; Insert DL; List<Delivery__c> lstDeliverys = new List<Delivery__c>(); lstDeliverys.Add(DL);
ApexPages.currentPage().getParameters().get('OppID');
clsTest.ShowDeliverys();
Best, Regards.
- maiyaku
- August 03, 2012
- Like
- 0
Google Maps not show when add latitude and longitude
I try to add latitude and longitude to google maps. but it not show.
I would like to use latitude, longitude without the address ?
Page
<apex:page standardController="Sales_Visit__c"> <c:GoogleMapsInternational latitude="{!Sales_Visit__c.Latitude__c}" longitude="{!Sales_Visit__c.Longitude__c}" iconColour="#236FBD" width="700" height="700" backgroundColour="#FFFFFF" /> </apex:page>
Component
<apex:component > <apex:attribute name="googleMapAPIKey" description="Google maps API key needed to generate map, sign up at http://code.google.com/apis/maps/signup.html" type="string" default="CHANGE_ME"/> <apex:attribute name="googleMapURL" description="URL of Google map for example http://maps.google.com, http://maps.google.fr, http://maps.google.es, http://maps.google.co.uk, etc" type="string" /> <apex:attribute name="height" description="Google map height in pixels" type="integer" default="200" /> <apex:attribute name="width" description="Google map width in pixels" type="integer" default="700" /> <apex:attribute name="latitude" description="Current latitude" type="Double" /> <apex:attribute name="longitude" description="Current longitude" type="Double" /> <apex:attribute name="iconColour" description="Colour of icon marker in map for example #236FBD and #8A9EBE (colours for account)and #56458C (colours for contact)" type="string" default="#FF0000" /> <apex:attribute name="backgroundColour" description="Background Colour around the Google Map for example set to #FFFFFF to change from default salesforce background colour" type="string" default="#F3F3EC" /> <apex:attribute name="address" description="Address to search for in Google maps, including the country in the address helps accuraccy" type="string" /> <apex:outputPanel id="top_level_panel" layout="block" style="background-color: {!backgroundColour}; margin-left: auto; margin-right: auto"> <apex:outputPanel id="map_canvas" layout="block" style="width: {!width}px; height: {!height}px; margin-left: auto; margin-right: auto"> </apex:outputPanel> </apex:outputPanel> <div id="hiddenFieldAddress" style="display:none">{!address}</div> <div id="hiddenFieldLocalAddressFound" style="display:none">{!$Label.GMI_LocalAddressFound}</div> <div id="hiddenFieldLocalAddressNotFound" style="display:none">{!$Label.GMI_LocalAddressNotFound}</div> <div id="hiddenFieldLocalShowMap" style="display:none">{!$Label.GMI_LocalShowMap}</div> <div id="hiddenFieldErrorHeader" style="display:none">{!$Label.GMI_GenerateKey}</div> <div id="hiddenFieldErrorDetails" style="display:none">{!$Label.GMI_UpdateComponent}</div> <div id="hiddenFieldErrorWebsite" style="display:none">{!$Label.GMI_WebsiteNeeded}</div> <div id="hiddenFieldGoogleLanguageCode" style="display:none">{!$Label.GMI_GoogleLanguageCode}</div> <div id="hiddenFieldgoogleMapURL" style="display:none">{!$Label.GMI_googleMapURL}</div> <div id="hiddenFieldgoogleMapURLOverride" style="display:none">{!googleMapURL}</div> <div id="hiddenFieldLatitude" style="display:none">{!latitude}</div> <div id="hiddenFieldLongitude" style="display:none">{!longitude}</div> <script type="text/javascript"> var safeAddress = document.getElementById('hiddenFieldAddress').innerHTML.replace(/\s+/g, ' '); var safelatitude = document.getElementById('hiddenFieldLatitude').innerHTML.replace(/\s+/g, ' '); var safelongitude = document.getElementById('hiddenFieldLongitude').innerHTML.replace(/\s+/g, ' '); var safeLocalAddressFound = document.getElementById('hiddenFieldLocalAddressFound').innerHTML.replace(/\s+/g, ' '); var safeLocalAddressNotFound = document.getElementById('hiddenFieldLocalAddressNotFound').innerHTML.replace(/\s+/g, ' '); var safeLocalShowMap = document.getElementById('hiddenFieldLocalShowMap').innerHTML.replace(/\s+/g, ' '); var safeErrorHeader = document.getElementById('hiddenFieldErrorHeader').innerHTML.replace(/\s+/g, ' '); var safeErrorDetails = document.getElementById('hiddenFieldErrorDetails').innerHTML.replace(/\s+/g, ' '); var safeErrorWebsite = document.getElementById('hiddenFieldErrorWebsite').innerHTML.replace(/\s+/g, ' '); var safeGoogleLanguageCode = document.getElementById('hiddenFieldGoogleLanguageCode').innerHTML.replace(/\s+/g, ' '); </script> <script type="text/javascript"> // see if Google api URL override has been set var safeGoogleMapURL = document.getElementById('hiddenFieldgoogleMapURL').innerHTML.replace(/\s+/g, ' '); var safeGoogleMapURLOverride = document.getElementById('hiddenFieldgoogleMapURLOverride').innerHTML.replace(/\s+/g, ' '); if (safeGoogleMapURLOverride != "") { safeGoogleMapURL = safeGoogleMapURLOverride; } //change google api document.write('<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&aLoc={!latitude}&zLoc={!longitude}&key=ABQIAAAAqxV-CxuhXx_fdbYnCi75TxSwuLiTNBOhuAjJ8jE06OTy4MFh9BS9pLQLodvQx9Odv8UPA6g4H7Y6Aw"><\/scr' + 'ipt>'); </script> <script src="{!URLFOR($Resource.GoogleMapsInternational, 'googleMapsInternational.js')}" type="text/javascript"></script> <script type="text/javascript"> // run initialize initialize( safelatitude, '{!latitude}', safelongitude , '{!longitude}', '{!iconColour}', safeGoogleMapURL, '{!width}', '{!height}', safeGoogleLanguageCode, safeLocalAddressFound, safeLocalAddressNotFound, safeLocalShowMap, safeErrorHeader, safeErrorDetails, safeErrorWebsite, '{!$Component.map_canvas}' ); </script> </apex:component>
Thank you.
- maiyaku
- April 26, 2012
- Like
- 0
Error Deployment
Failure Message: "System.QueryException: unexpected token: '('", Failure Stack Trace: "Class.BDAPP.QueryRelationShip: line 173, column 1 Class.BDAPP.RunBDAPP: line 63, column 1 Class.BDAPP.execute: line 21, column 1"
Start Line 163 and End Line 173
WhereCondition = 'ID In(' + RelationshipQueRy + ')'; Query = 'Select ID, Contact_ID__c, Account_ID__c, Rev_Contact_ID__c,Rev_Account_ID__c,Rev_Account_ID__r.Loyalty__c,Rev_Account_ID__r.CustomerPriority__c,Rev_Contact_ID__r.Account_Number__c,Rev_Account_ID__r.List_Office__c, '; Query += 'Contact_ID__r.name, Rev_Contact_ID__r.name, Account_ID__r.name, Rev_Account_ID__r.Name,Rev_Account_ID__r.BP_Type__c,Position__c,Relationship_Category__r.name,Rev_Contact_ID__r.AccountMarkDelStatus__c, '; Query += 'Position_Group__c,Contact_ID__r.AccountId,Rev_Account_ID__r.AccountNumber,Contact_ID__r.Phone,Contact_ID__r.MobilePhone,Relationship_Category__r.Relation_to_Owner_TH__c,Rev_Account_ID__r.List_Sales_Rep__c,Rev_Account_ID__r.List_District__c, '; Query += 'Contact_ID__r.Sex__c,Rev_Contact_ID__r.Sex__c,Relationship_Category__r.Reverse_Relationship_Category__r.name,Rev_Contact_ID__r.AccountID,Rev_Contact_ID__r.Account_Name__c,Rev_Account_ID__r.Mark_for_Delete__c '; Query += 'FROM Relationship__c '; Query += 'Where ' + WhereCondition; List<sObject> SRelation = Database.Query(Query);
Thank you so much.
- maiyaku
- April 01, 2012
- Like
- 0
Cut Outside Iframe Problem !
I want move Standart Lead Page with ifame to Home
I do not want something that is out of the red. I can cut it out to me ?
<apex:page sidebar="False" showHeader="False"> <apex:form > <iframe width="100%" height="600" frameborder="0" scrolling="true" id="theiframe" marginheight="0" marginwidth="0" rendered="true" src="https://na14.salesforce.com/00Q?fcf=00Bd0000003rrII#"></iframe> </apex:form> </apex:page>
Thank you.
- maiyaku
- March 14, 2012
- Like
- 0
Database Query this error unexpected token
caused by: System.QueryException: unexpected token: '('
Public MD_Sales_Group_Initials__c getMSGI(List<ID> SalesRepName){ String MSGIQuery = ''; List<MD_Sales_Group_Initials__c> lstMSGI = New List<MD_Sales_Group_Initials__c> (); MD_Sales_Group_Initials__c MSGI = New MD_Sales_Group_Initials__c (); MSGIQuery = 'Select id,Name,Code__c From MD_Sales_Group_Initials__c Where ID In (' + SalesRepName + ')'; List<sObject> Qmsgi = Database.Query(MSGIQuery); if(Qmsgi != null && Qmsgi.size()>0){ for(sObject s: Qmsgi){ lstMSGI.add((MD_Sales_Group_Initials__c)s); } } if(lstMSGI != null && lstMSGI.size() > 0){ MSGI = lstMSGI[0]; } Return MSGI; }
MSGIQuery = 'Select id,Name,Code__c From MD_Sales_Group_Initials__c Where ID In (' + SalesRepName + ')';
Thank you.
- maiyaku
- March 08, 2012
- Like
- 0
Use Value in Static Resource put in VF Page Google Maps
<table>
<tr><td>Street:</td><td width="61%" id="AccountStreet"></td></tr>
^ Static Resource Value
<tr><td>City:</td><td width="61%" id="AccountCity"></td></tr>
<tr><td>State/Province:</td><td width="61%" id="AccountSP"></td></tr>
<tr><td>Zip/Postal Code:</td><td width="61%" id="AccountZP"></td></tr>
<tr><td>Country:</td><td width="61%" id="AccountCountry"></td></tr>
<tr><br></br></tr>
</table>
<table>
<tr><td>Phone:</td><td width="47%" id="AccountPhone"></td></tr>
<tr><td>Website:</td><td width="47%" id="AccountWebsite"></td></tr>
<tr><br></br></tr>
</table>
<table>
<p></p>
<c:GoogleMapsInternational iconColour="#236FBD"
width="700"
height="700"
backgroundColour="#FFFFFF"
address="{!Acc.Street__c} {!Acc.City__c} {!Acc.State_Province__c}
^Put to address value for google map
{!Acc.Zip_Postal_Code__c} {!Acc.Country__c}" /> </table>
I can take the Static Resource Value put in address value ? Help me about this.
Thank you so much.
- maiyaku
- January 16, 2012
- Like
- 0
Page is not show list data in html 5
I'm fairly new to using html 5 Please advise.
The first query is object Account it work. but secord query is object Opportunity is not work, page is not show list opportunity.
I think it would be wrong to this Static Resources. this code all
Interface
Customer Visit is work and Order View not show list when cilck.
When click Order View
this code
global with sharing class AccountController { information @RemoteAction global static List<Account> queryAlbums() { return [SELECT Id,Name,Customer_Number__c,Business__c,Pay_Type__c,Term__c,Phone,Website, Street__c, State_Province__c, Zip_Postal_Code__c, Country__c, City__c FROM Account Where Customer_Number__c != null LIMIT 5]; } @RemoteAction global static List<Opportunity> queryOpp() { return [SELECT Id,Name, OrderNumber__c, Amount,StageName, MainCompetitors__c,Probability,AccountID,TrackingNumber__c,CurrentGenerators__c FROM Opportunity]; } }
and static Resources
var currentAlbums = new Array(); var currentOpp = new Array(); var $j = jQuery.noConflict(); $j(document).ready(function() { if(window.location.href.indexOf('#') > 0) { window.location.href = window.location.href.split("#")[0]; } addPageListeners(); getAlbums(function(){ $j.mobile.hidePageLoadingMsg(); }); }); function addPageListeners() { $j('#addalbum').live('pagebeforeshow', function () { $j("#albumNameTxt").val(''); }); $j('#addOpportunity').live('pagebeforeshow', function () { $j("#OppNameTxt").val(''); }); $j('#addtrack').live('pagebeforeshow', function () { $j("#trackNameTxt").val(''); $j("#trackPriceTxt").val(0.00); }); } function getAlbums(callback) { $j('#albumlist').empty(); AccountController.queryAlbums(function(records, e) { showAlbums(records, callback) }, {escape:true}); } function showAlbums(records, callback) { currentAlbums.length = 0; for(var i = 0; i < records.length; i++) { currentAlbums[records[i].Id] = records[i]; } var x = 0; $j.each(records, function() { $j('<li></li>') .attr('id',this.Id) .hide() .append('<h2>' + this.Name + '</h2>') .click(function(e) { e.preventDefault(); $j.mobile.showPageLoadingMsg(); $j('#AlbumName').html(currentAlbums[this.id].Name); $j('#AlbumNumber').html(currentAlbums[this.id].Customer_Number__c); $j('#AccountBusiness').html(currentAlbums[this.id].Business__c); $j('#AccountPayType').html(currentAlbums[this.id].Pay_Type__c); $j('#AccountTerm').html(currentAlbums[this.id].Term__c); $j('#AccountPhone').html(currentAlbums[this.id].Phone); $j('#AccountWebsite').html(currentAlbums[this.id].Website); $j('#AccountStreet').html(currentAlbums[this.id].Street__c); $j('#AccountSP').html(currentAlbums[this.id].State_Province__c); $j('#AccountZP').html(currentAlbums[this.id].Zip_Postal_Code__c); $j('#AccountCountry').html(currentAlbums[this.id].Country__c); $j('#AccountCity').html(currentAlbums[this.id].City__c); }) .appendTo('#albumlist') .show(); x++; }); $j('#albumlist').listview('refresh'); if(callback != null) { callback(); } } //this start not work function getOpps(callback) { $j('#Oppslist').empty(); AccountController.queryOpp(function(records, e) { showOpps(records, callback) }, {escape:true}); } function showOpps(records, callback) { currentOpp.length = 0; for(var i = 0; i < records.length; i++) { currentOpp[records[i].Id] = records[i]; } var x = 0; $j.each(records, function() { $j('<li></li>') .attr('id',this.Id) .hide() .append('<h2>' + this.Name + '</h2>') .click(function(e) { e.preventDefault(); $j.mobile.showPageLoadingMsg(); $j('#OppName').html(currentOpp[this.id].Name); }) .appendTo('#Oppslist') .show(); x++; }); $j('#Oppslist').listview('refresh'); if(callback != null) { callback(); } }
this VF Page
<apex:page showHeader="false" standardStylesheets="false" cache="true" controller="AccountController" > <apex:outputText escape="false" value="{!'<!DOCTYPE html>'}"/> <html> <head> <title>MarketingApp</title> <link rel="stylesheet" href="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.mobile-1.0rc2.min.css')}" /> <script type="text/javascript" src="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.min.js')}"></script> <script type="text/javascript" src="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.mobile-1.0rc2.min.js')}"></script> <script type="text/javascript" src="{!URLFOR($Resource.MarketingApp)}"></script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> </head> <body> <div data-role="page" data-theme="b" id="mainpage"> <div data-role="header"> <a href='#' id="logout" class='ui-btn-left' data-icon='home' >Home</a> <h1>Main Menu</h1> </div> <div data-role="content"> <ul data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b" align="center"> <a href='#detailpage' style="text-decoration:none"><font color="#363636" size="3"><br><dd>Customer Visit</dd></br></font></a> </ul> <ul data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b" align="center"> <a href='#Opppage' style="text-decoration:none"><font color="#363636" size="3"><br><dd>Order View</dd></br></font></a> </ul> </div> </div> <div data-role="page" data-theme="b" id="detailpage"> <div data-role="header"> <a href='#mainpage' id="backAlbum" class='ui-btn-left' data-icon='arrow-l' data-direction="reverse">Home</a> <h1>Customer List</h1> </div> <div data-role="content"> <a href='#trackpage' style="text-decoration:none"><font color="#363636" size="3"> <input type="hidden" id="albumId" /> <ul id="albumlist" data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b"> </ul> </font></a> </div> </div> <div data-role="page" data-theme="b" id="Opppage"> <div data-role="header"> <a href='#mainpage' id="backAlbum" class='ui-btn-left' data-icon='arrow-l' data-direction="reverse">Home</a> <h1>Order List</h1> </div> <input type="hidden" id="OppId" /> <ul id="Oppslist" data-inset="true" data-role="listview" data-theme="c" data-dividertheme="a"> </ul> </div> </body> </html> </apex:page>
thank you very much.
- maiyaku
- January 13, 2012
- Like
- 0
Page is not show list data in html 5
I'm fairly new to using html 5 Please advise.
The first query is object Account it work. but secord query is object Opportunity is not work, page is not show list opportunity.
I think it would be wrong to this Static Resources. this code all
Interface
Customer Visit is work and Order View not show list when cilck.
When click Order View
this code
global with sharing class AccountController { information @RemoteAction global static List<Account> queryAlbums() { return [SELECT Id,Name,Customer_Number__c,Business__c,Pay_Type__c,Term__c,Phone,Website, Street__c, State_Province__c, Zip_Postal_Code__c, Country__c, City__c FROM Account Where Customer_Number__c != null LIMIT 5]; } @RemoteAction global static List<Opportunity> queryOpp() { return [SELECT Id,Name, OrderNumber__c, Amount,StageName, MainCompetitors__c,Probability,AccountID,TrackingNumber__c,CurrentGenerators__c FROM Opportunity]; } }
and static Resources
var currentAlbums = new Array(); var currentOpp = new Array(); var $j = jQuery.noConflict(); $j(document).ready(function() { if(window.location.href.indexOf('#') > 0) { window.location.href = window.location.href.split("#")[0]; } addPageListeners(); getAlbums(function(){ $j.mobile.hidePageLoadingMsg(); }); }); function addPageListeners() { $j('#addalbum').live('pagebeforeshow', function () { $j("#albumNameTxt").val(''); }); $j('#addOpportunity').live('pagebeforeshow', function () { $j("#OppNameTxt").val(''); }); $j('#addtrack').live('pagebeforeshow', function () { $j("#trackNameTxt").val(''); $j("#trackPriceTxt").val(0.00); }); } function getAlbums(callback) { $j('#albumlist').empty(); AccountController.queryAlbums(function(records, e) { showAlbums(records, callback) }, {escape:true}); } function showAlbums(records, callback) { currentAlbums.length = 0; for(var i = 0; i < records.length; i++) { currentAlbums[records[i].Id] = records[i]; } var x = 0; $j.each(records, function() { $j('<li></li>') .attr('id',this.Id) .hide() .append('<h2>' + this.Name + '</h2>') .click(function(e) { e.preventDefault(); $j.mobile.showPageLoadingMsg(); $j('#AlbumName').html(currentAlbums[this.id].Name); $j('#AlbumNumber').html(currentAlbums[this.id].Customer_Number__c); $j('#AccountBusiness').html(currentAlbums[this.id].Business__c); $j('#AccountPayType').html(currentAlbums[this.id].Pay_Type__c); $j('#AccountTerm').html(currentAlbums[this.id].Term__c); $j('#AccountPhone').html(currentAlbums[this.id].Phone); $j('#AccountWebsite').html(currentAlbums[this.id].Website); $j('#AccountStreet').html(currentAlbums[this.id].Street__c); $j('#AccountSP').html(currentAlbums[this.id].State_Province__c); $j('#AccountZP').html(currentAlbums[this.id].Zip_Postal_Code__c); $j('#AccountCountry').html(currentAlbums[this.id].Country__c); $j('#AccountCity').html(currentAlbums[this.id].City__c); }) .appendTo('#albumlist') .show(); x++; }); $j('#albumlist').listview('refresh'); if(callback != null) { callback(); } } //this start not work function getOpps(callback) { $j('#Oppslist').empty(); AccountController.queryOpp(function(records, e) { showOpps(records, callback) }, {escape:true}); } function showOpps(records, callback) { currentOpp.length = 0; for(var i = 0; i < records.length; i++) { currentOpp[records[i].Id] = records[i]; } var x = 0; $j.each(records, function() { $j('<li></li>') .attr('id',this.Id) .hide() .append('<h2>' + this.Name + '</h2>') .click(function(e) { e.preventDefault(); $j.mobile.showPageLoadingMsg(); $j('#OppName').html(currentOpp[this.id].Name); }) .appendTo('#Oppslist') .show(); x++; }); $j('#Oppslist').listview('refresh'); if(callback != null) { callback(); } }
this VF Page
<apex:page showHeader="false" standardStylesheets="false" cache="true" controller="AccountController" > <apex:outputText escape="false" value="{!'<!DOCTYPE html>'}"/> <html> <head> <title>MarketingApp</title> <link rel="stylesheet" href="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.mobile-1.0rc2.min.css')}" /> <script type="text/javascript" src="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.min.js')}"></script> <script type="text/javascript" src="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.mobile-1.0rc2.min.js')}"></script> <script type="text/javascript" src="{!URLFOR($Resource.MarketingApp)}"></script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> </head> <body> <div data-role="page" data-theme="b" id="mainpage"> <div data-role="header"> <a href='#' id="logout" class='ui-btn-left' data-icon='home' >Home</a> <h1>Main Menu</h1> </div> <div data-role="content"> <ul data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b" align="center"> <a href='#detailpage' style="text-decoration:none"><font color="#363636" size="3"><br><dd>Customer Visit</dd></br></font></a> </ul> <ul data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b" align="center"> <a href='#Opppage' style="text-decoration:none"><font color="#363636" size="3"><br><dd>Order View</dd></br></font></a> </ul> </div> </div> <div data-role="page" data-theme="b" id="detailpage"> <div data-role="header"> <a href='#mainpage' id="backAlbum" class='ui-btn-left' data-icon='arrow-l' data-direction="reverse">Home</a> <h1>Customer List</h1> </div> <div data-role="content"> <a href='#trackpage' style="text-decoration:none"><font color="#363636" size="3"> <input type="hidden" id="albumId" /> <ul id="albumlist" data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b"> </ul> </font></a> </div> </div> <div data-role="page" data-theme="b" id="Opppage"> <div data-role="header"> <a href='#mainpage' id="backAlbum" class='ui-btn-left' data-icon='arrow-l' data-direction="reverse">Home</a> <h1>Order List</h1> </div> <input type="hidden" id="OppId" /> <ul id="Oppslist" data-inset="true" data-role="listview" data-theme="c" data-dividertheme="a"> </ul> </div> </body> </html> </apex:page>
thank you very much.
- maiyaku
- January 12, 2012
- Like
- 0
For Loop not work in Test Class
Coverage 8% - -
Test Class is not work a red zone area
1 Public Class Tomoring { 2 3 public static void CreateTomoring() { 4 5 Integer EHODaybyMonth = 0; 6 Integer i; 7 8 DateTime DateNow = System.now(); 9 10 List<Time_Attendance__c> lstTA = [Select id,Agent_Name__c,Check_in__c,Check_out__c,RecordFinish__c,Time_Calculate__c from 11Time_Attendance__c Where Check_out__c = null]; 12 13 if((DateNow.Hour() + DateNow.Minute()) == 0){ 14 15** for(Time_Attendance__c TA : lstTA){ TA.Check_out__c = System.now() - 1; update TA; Time_Attendance__c TAC = new Time_Attendance__c (); TAC.Check_in__c = System.Now(); DateTime Ci = TAC.Check_in__c ; DateTime Co = TAC.Check_Out__c ; TAC.Name = TA.Agent_Name__c + ' ' + Co.Day() + '/' + Co.Month() + '/' + Co.Year() + ' ' + Co.Hour() + ':' + Co.Minute(); TAC.RecordFinish__c = True; Double D,M,Y,H,MN = 0; if(Ci.Minute() > Co.Minute()){ if(Ci.Day() > Co.Day()){ if(Ci.Month() > Co.Month()){ Integer CalMonth = Co.Month() - Ci.Month(); Integer CalDay = Ci.Month(); for(i = Ci.Month();i < Co.Month();i++){ IF(i == 1){ EHODaybyMonth = 31*24;} Else IF(i == 2){ EHODaybyMonth = 28*24;} Else IF(i == 3){ EHODaybyMonth = 31*24;} Else IF(i == 4){ EHODaybyMonth = 30*24;} Else IF(i == 5){ EHODaybyMonth = 31*24;} Else IF(i == 6){ EHODaybyMonth = 30*24;} Else IF(i == 7){ EHODaybyMonth = 31*24;} Else IF(i == 8){ EHODaybyMonth = 31*24;} Else IF(i == 9){ EHODaybyMonth = 30*24;} Else IF(i == 10){ EHODaybyMonth = 31*24;} Else IF(i == 11){ EHODaybyMonth = 30*24;} Else IF(i == 12){ EHODaybyMonth = 31*24;} CalDay = CalDay + EHODaybyMonth ; } D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D + CalDay) - 1; MN = ((Co.Minute() + 60) - Ci.Minute()); } Else{ //CoMonth less than CiDay D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D) - 1; MN = ((Co.Minute() + 60) - Ci.Minute()); } } Else{ //CoDay less than CiDay if(Co.Month() > Ci.Month()){ H = ((Co.Hour() - Ci.Hour()) ) - 1; MN = ((Co.Minute() + 60) - Ci.Minute()); } } } Else{ if(Co.Day() > Ci.Day()){ if(Co.Month() > Ci.Month()){ Integer CalMonth = Co.Month() - Ci.Month(); Integer CalDay = Ci.Month(); for(i = Ci.Month();i < Co.Month();i++){ IF(i == 1){ EHODaybyMonth = 31*24;} Else IF(i == 2){ EHODaybyMonth = 28*24;} Else IF(i == 3){ EHODaybyMonth = 31*24;} Else IF(i == 4){ EHODaybyMonth = 30*24;} Else IF(i == 5){ EHODaybyMonth = 31*24;} Else IF(i == 6){ EHODaybyMonth = 30*24;} Else IF(i == 7){ EHODaybyMonth = 31*24;} Else IF(i == 8){ EHODaybyMonth = 31*24;} Else IF(i == 9){ EHODaybyMonth = 30*24;} Else IF(i == 10){ EHODaybyMonth = 31*24;} Else IF(i == 11){ EHODaybyMonth = 30*24;} Else IF(i == 12){ EHODaybyMonth = 31*24;} CalDay = CalDay + EHODaybyMonth ; } D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D + CalDay); MN = (Co.Minute() - Ci.Minute()) ; //System.AssertEquals('','Else ' + D + ': ' + M); } Else{ D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D); MN = (Co.Minute() - Ci.Minute()) ; } } Else{ H = ((Co.Hour() - Ci.Hour())); MN = (Co.Minute() - Ci.Minute()) ; } } TAC.Time_Calculate__c = H+(MN/100); insert TAC; } } }
this Line 15 more is a red zone not work
Static testmethod void TestTomoring () { CreateTomoring(); Profile p = [select id from profile where name = 'System Administrator']; User Ua = New User(); Ua.Assignment_Group_Active__c = True; Ua.CountClick__c = 2; Ua.EditbySup__c = False; Ua.profileid = p.Id; Ua.Username = 'Test@sccc.co.th'; Ua.FirstName = 'hello'; Ua.LastName = 'Test'; Ua.Email = 'Test@sccc.co.th'; Ua.Alias = 'HTA'; Ua.isActive = true; Ua.emailencodingkey='UTF-8'; Ua.timezonesidkey='America/Los_Angeles'; Ua.CommunityNickname = 'OKTEST'; Ua.localesidkey='en_US'; Ua.languagelocalekey='en_US'; insert Ua; Time_Attendance__c TAC = New Time_Attendance__c(); TAC.Check_in__c = System.Now(); TAC.Name = 'Test' + System.Now(); TAC.RecordFinish__c = True; TAC.Time_Calculate__c = 12.3; insert TAC; TAC.Check_out__c = System.now() - 1; Update TAC; List<Time_Attendance__c> lstTA = [Select id,Agent_Name__c,Check_in__c,Check_out__c,RecordFinish__c,Time_Calculate__c from Time_Attendance__c Where Check_out__c = null]; for(Time_Attendance__c TA : lstTA){ TA.Check_out__c = System.now() - 1; Update TA; Time_Attendance__c TAC1 = New Time_Attendance__c(); TAC1.Check_in__c = System.Now(); TAC1.Name = 'Test' + System.Now(); TAC1.RecordFinish__c = True; TAC1.Time_Calculate__c = 12.3; insert TAC1; } } }
Thank you.
Happy new year !
- maiyaku
- December 27, 2011
- Like
- 0
Constructor not defined in Test Class
Class is use override view record. I can open but Test Class not work !
public class genMembershipConditionsPDF{ public genMembershipConditionsPDF(ApexPages.StandardController controller) { gotoPDFPage(); } public Pagereference gotoPDFPage() { return new Pagereference('/apex/MembershipConditionsPDF?Id='+Apexpages.Currentpage().getParameters().get('Id')); } }
@isTest private class test_genMembershipConditionsPDF { static testMethod void myUnitTest() { Account Acc = new Account(); Acc.name = 'Test'; insert Acc; Membership_Conditions__c MC = new Membership_Conditions__c(); MC.Copy_of_organisational_structure__c = True; MC.OrganizationsID__c = Acc.id; MC.Designation__c = 'Test'; insert MC; ApexPages.StandardSetController controller = new ApexPages.StandardSetController(MC); genMembershipConditionsPDF sc = new genMembershipConditionsPDF(); PageReference S = sc.gotoPDFPage(); } }
Thank you so much.
- maiyaku
- November 24, 2011
- Like
- 0
Alert Popup in page not work
I want check country account this page is match country visited object. But it not work not show when click save
public PageReference save() { Account AccS = [Select id,Country__c from Account Where id =: objCus[0].AccountID__c]; String CountryName = Accs.Country__c; Boolean CheckCountry = False; List<Country_Visited__c> lstCRV = [Select id,Name from Country_Visited__c Where Customer_Visit_ReportID__c =: objCus[0].Customer_Visit_ReportID__c]; for(Country_Visited__c CRV : lstCRV){ if(CRV.Name == CountryName){ CheckCountry = True; } } if(CheckCountry == True){ if(objCus.size()>0) { CountryVisited(); List<Customer_Visited__c > lstCV = [Select id from Customer_Visited__c Where AccountID__c =: objCus[0].AccountID__c]; objCus[0].Nums__c = lstCV.size(); insert objCus; CusID = objCus[0].id; } insertExistingProduct(); insertNewProduct(); insertTask(); CreateOpportunity(); return Cancel(); } showmessage = 'True'; return null; } public string showmessage { get;set; }
Page
<apex:pageBlock id="pageBlock" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}" rerender="error" onclick="showmsg()"/> <apex:commandButton value="Cancel" action="{!Cancel}" rerender="error"/> </apex:pageBlockButtons> </apex:pageBlock> <script> function showmsg(){ if('{!showMessage}'=='True'){ alert('your message!'); return false; } } </script>
Thank so much.
- maiyaku
- November 14, 2011
- Like
- 0
Test Class this error
one error is null id after insert
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PopAccounttoPayment: execution of AfterInsert caused by: System.StringException: Invalid id: Trigger.PopAccounttoPayment: line 16, column 42:
trigger PopAccounttoPayment on Payment_Line__c (after insert) { set<ID> setInvID = new set<ID>(); for(Payment_Line__c Pml : trigger.new){ if(Pml.Invoice_BC__c != null || Pml.Invoice_BC__c != ''){ setInvID.Add(Pml.Invoice_BC__c); } } Invoice_BC__c InvBC = new Invoice_BC__c(); List<Invoice_BC__c> lstInvBC = [Select id,AccountID__c from Invoice_BC__c Where id in : setInvID]; if(lstInvBC.size() != 0){ InvBC = lstInvBC[0]; } if(InvBC.AccountID__c != null && InvBC.AccountID__c != ''){ Payment_Line__c pml = Trigger.new[0]; List<Payments__c> lstPm = new List<Payments__c>(); Payments__c Pm = new Payments__c(id = pml.DocNo__c); Pm.AccountID__c = InvBC.AccountID__c; lstPm.Add(Pm); Update lstPm; } }
Test class
@isTest private class TestPopAccounttoPayment{ static testMethod void myTest() { Account objAcc = new Account(); objAcc.Name = 'test'; insert objAcc; Opportunities__c objOpp = new Opportunities__c(); objOpp.Account_Name__c = objAcc.Id; insert objOpp; Quotes__c objQuo = new Quotes__c(); objQuo.Account_Name__c = objAcc.Id; objQuo.OpportunitiesID__c = objOpp.Id; insert objQuo; Sales_Order__c objSOD = new Sales_Order__c(); objSOD.Name = 'test4'; objSOD.OpportunitiesID__c = objOpp.Id; objSOD.Quotes__c = objQuo.Id; insert objSOD; Invoice_BC__c objInvBc = new Invoice_BC__c(); objInvBc.Name = 'Test5'; objInvBc.Sales_OrderID__c = objSOD.id; objInvBc.AccountID__c = objAcc.id; insert objInvBc; Payments__c objPay = new Payments__c(); objPay.Name = 'Test2'; objPay.Due_Date__c = System.Today(); objPay.AccountID__c = objInvBc.AccountID__c; insert objPay; Test.StartTest(); Payment_Line__c objPayLine = new Payment_Line__c(); ApexPages.currentPage().getParameters().put('id', objPay.id); objPayLine.Name = 'Test3'; objPayLine.DocNo__c = objPay.id; objPayLine.Invoice_BC__c = objInvBc.id; insert objPayLine; Payments__c objPay2 = new Payments__c(); ApexPages.currentPage().getParameters().put('id', objPayLine.DocNo__c); objPay2.Name = 'Test2'; objPay2.Due_Date__c = System.Today(); objPay2.AccountID__c = objInvBc.AccountID__c; insert objPay2; update objPay2; Test.StopTest(); } }
thank you so much
- maiyaku
- August 30, 2011
- Like
- 0
Loop not work in Test Class
i'm wright test class full loop , because problem for loop
trigger MarkforDelAllinCon on Contact(before Update) { set<ID> setContactID = new set<ID>(); for(Contact Con: Trigger.new){ if(Con.MarkforDelete__c == true){ setContactID.Add(Con.id); } } List<Relationship__c > lstRel = [Select id,Mark_for_Delete__c,Contact_ID__c,Account_ID__c,Rev_Account_ID__c,Rev_Contact_ID__c from Relationship__c Where Contact_ID__c in : setContactID and Mark_for_Delete__c !=: True]; List<Relationship__c> Rel = new List<Relationship__c>(); for(Contact Con: Trigger.new){ if(lstRel.size() != 0 ){ for(Relationship__c Res : lstRel){ Res.Contact_ID__c = Con.id; Res.Rev_Contact_ID__c = Con.id; Res.Mark_for_Delete__c = true; Rel.Add(Res); } update Rel; } } }
for(Relationship__c Res : lstRel){
Res.Contact_ID__c = Con.id;
Res.Rev_Contact_ID__c = Con.id;
Res.Mark_for_Delete__c = true;
Rel.Add(Res);
}
update Rel;
}
@isTest private class TestMarkforDelAllinCon { static testMethod void myTest() { Test.StartTest(); Account objAcc = new Account(); objAcc.Name = 'testAcc1'; objAcc.AccountNumber = 'TestA00001'; insert objAcc; Account objAccRev = new Account(); objAccRev.Name = 'testAcc2'; objAccRev.AccountNumber = 'TestA00001'; insert objAccRev; Contact con = new Contact(); con.AccountID = objAcc.id; con.LastName = 'TestCon1'; con.MarkforDelete__c = True; insert con; update con; Contact ConRev = new Contact(); ConRev.AccountID = objAcc.id; ConRev.LastName = 'TestCon2'; ConRev.MarkforDelete__c = True; insert conRev; update conRev; Relationship__c Rel = new Relationship__c(); List<Relationship__c > lstRel = [Select id,Mark_for_Delete__c,Contact_ID__c,Account_ID__c,Rev_Account_ID__c,Rev_Contact_ID__c from Relationship__c Where Contact_ID__c =: con.id and Mark_for_Delete__c !=: True]; if(lstRel.size() != 0){ ApexPages.currentPage().getParameters().put('id',con.id); Rel.Contact_ID__c = Con.id; Rel.Rev_Contact_ID__c = Con.id; Rel.Mark_for_Delete__c = true; update Rel ; } Test.StopTest(); } }
a red line is problem
thank you so much
- maiyaku
- July 23, 2011
- Like
- 0
Error List has no rows
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SumSodcSync: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.SumSodcSync: line 4, column 31: []
trigger SumSodcSync on Sales_Order_Complete__c(After insert) {
for(Sales_Order_Complete__c sodc:trigger.new){
Sales_Order__c Sod = [Select id from Sales_Order__c Where id = : ApexPages.currentPage().getParameters().get('id')];
Sales_Order_Complete__c[] Scom = [Select id,OpportunitiesID__c ,DimensionTxWxL__c,Grade__c,Total_Weight__c,Quotes__c,
Fail__c, Name, Products__c, Quantity__c,Quantity_Remain__c,Sales_OrderID__c,Success__c,Date__c,Pop__c,
Sales_Order_Line_ItemID__c,Deliver_Remain__c,Delivery_Good_Pcs__c,Order_Quantity__c,Total_Finished_Good__c ,
Delivery_Good_Ton__c,Delivery_Remain_Ton__c,Finished_Good_Remain__c,Finished_Good_Remain_Ton__c,Finished_Tons__c
from Sales_Order_Complete__c where Sales_OrderID__c =: sod.id And Pop__c != true ];
Sodc_Sumary__c[] objssc = new Sodc_Sumary__c[]{};
Sodc_Sumary__c Sc = new Sodc_Sumary__c();
for(Sales_Order_Complete__c Ssc: Scom ){
Sc = new Sodc_Sumary__c();
Sc.Sales_Order__c = Ssc.Sales_OrderID__c;
Sc.Dimen__c = Ssc.DimensionTxWxL__c;
Sc.Grade__c = Ssc.Grade__c;
Sc.Order_Status__c = Ssc.Id;
Sc.Name = Ssc.Name;
Sc.Finished_Good_Remain__c = Ssc.Finished_Good_Remain__c;
Sc.Finished_Good_Remain_Ton__c = Ssc.Finished_Good_Remain_Ton__c;
Sc.Deliver_Remain__c= Ssc.Deliver_Remain__c;
Sc.Delivery_Remain_Ton__c = Ssc.Delivery_Remain_Ton__c;
Sc.Quantity__c = Ssc.Order_Quantity__c;
objssc.add(Sc);
}
insert objssc;
}
}
Please guide me or sample
Thank you so much
- maiyaku
- May 25, 2011
- Like
- 0
I Problem DateTime Calculate
Integer A; ca.SLAs__c = A*60; ca.Expiration_Date__c = ca.CreatedDate.Minute()+ca.SLAs__c;
Error: Compile Error: Illegal assignment from Decimal to Datetime at line 197 column 1
Thank you so much.
- maiyaku
- May 21, 2011
- Like
- 0
Code Coverage 46% I can add it to me?
Average Code now 46% I can Add to me?
trigger ContractsSync on Contracts__c(after insert) { for(Contracts__c COL:trigger.new){ if(COL.id != Null ){ Quotes_Line_Item__c[] QuoLine= [Select Id, Name,QuotesID__c,Plant_Manager_Acceptation__c,Unit_Price__c,Quantity__c,Total_Weight__c From Quotes_Line_Item__c where QuotesID__c= :COL.Quotes__c And Plant_Manager_Acceptation__c = 'Accept']; Contracts_LineItem__c[] CLI = new Contracts_LineItem__c[]{}; Contracts_LineItem__c CL = new Contracts_LineItem__c(); for(Quotes_Line_Item__c QL: QuoLine){ CL = new Contracts_LineItem__c(); CL.Contracts__c = COL.id; CL.Quotes_Line_Item__c = QL.Id; CL.Unit_Price__c = QL.Unit_Price__c; CL.Quantity__c = QL.Quantity__c; CL.Total_Weight__c = QL.Total_Weight__c; CL.Name = QL.Name; CLI.add(CL); } insert CLI; } } }
Test
@isTest private class TestContractsSync{ static testMethod void myUnitTest() { Account Acc = new Account(Name='test'); insert Acc; Opportunities__c O = new Opportunities__c(Account_Name__c=Acc.Id,Stage__c='Prospecting'); insert O; Quotes__c Q = new Quotes__c(OpportunitiesID__c=O.Id); insert Q; Opportunities_Line_Item__c OL = new Opportunities_Line_Item__c(OpportunitiesID__c=O.Id); insert OL; Quotes_Line_Item__c QL = new Quotes_Line_Item__c(Name =OL.Name,QuotesId__c=Q.Id,Opportunities_Line_Item__c=OL.Id); insert QL; Contracts__c COT = new Contracts__c(Quotes__c = Q.id); insert COT; Contracts_LineItem__c COL = new Contracts_LineItem__c(Name='Test',Quotes_Line_Item__c = QL.id,Contracts__c = COT.id); insert COL; } }
Thank you so much.
- maiyaku
- May 08, 2011
- Like
- 0
Google Maps not show when add latitude and longitude
I try to add latitude and longitude to google maps. but it not show.
I would like to use latitude, longitude without the address ?
Page
<apex:page standardController="Sales_Visit__c"> <c:GoogleMapsInternational latitude="{!Sales_Visit__c.Latitude__c}" longitude="{!Sales_Visit__c.Longitude__c}" iconColour="#236FBD" width="700" height="700" backgroundColour="#FFFFFF" /> </apex:page>
Component
<apex:component > <apex:attribute name="googleMapAPIKey" description="Google maps API key needed to generate map, sign up at http://code.google.com/apis/maps/signup.html" type="string" default="CHANGE_ME"/> <apex:attribute name="googleMapURL" description="URL of Google map for example http://maps.google.com, http://maps.google.fr, http://maps.google.es, http://maps.google.co.uk, etc" type="string" /> <apex:attribute name="height" description="Google map height in pixels" type="integer" default="200" /> <apex:attribute name="width" description="Google map width in pixels" type="integer" default="700" /> <apex:attribute name="latitude" description="Current latitude" type="Double" /> <apex:attribute name="longitude" description="Current longitude" type="Double" /> <apex:attribute name="iconColour" description="Colour of icon marker in map for example #236FBD and #8A9EBE (colours for account)and #56458C (colours for contact)" type="string" default="#FF0000" /> <apex:attribute name="backgroundColour" description="Background Colour around the Google Map for example set to #FFFFFF to change from default salesforce background colour" type="string" default="#F3F3EC" /> <apex:attribute name="address" description="Address to search for in Google maps, including the country in the address helps accuraccy" type="string" /> <apex:outputPanel id="top_level_panel" layout="block" style="background-color: {!backgroundColour}; margin-left: auto; margin-right: auto"> <apex:outputPanel id="map_canvas" layout="block" style="width: {!width}px; height: {!height}px; margin-left: auto; margin-right: auto"> </apex:outputPanel> </apex:outputPanel> <div id="hiddenFieldAddress" style="display:none">{!address}</div> <div id="hiddenFieldLocalAddressFound" style="display:none">{!$Label.GMI_LocalAddressFound}</div> <div id="hiddenFieldLocalAddressNotFound" style="display:none">{!$Label.GMI_LocalAddressNotFound}</div> <div id="hiddenFieldLocalShowMap" style="display:none">{!$Label.GMI_LocalShowMap}</div> <div id="hiddenFieldErrorHeader" style="display:none">{!$Label.GMI_GenerateKey}</div> <div id="hiddenFieldErrorDetails" style="display:none">{!$Label.GMI_UpdateComponent}</div> <div id="hiddenFieldErrorWebsite" style="display:none">{!$Label.GMI_WebsiteNeeded}</div> <div id="hiddenFieldGoogleLanguageCode" style="display:none">{!$Label.GMI_GoogleLanguageCode}</div> <div id="hiddenFieldgoogleMapURL" style="display:none">{!$Label.GMI_googleMapURL}</div> <div id="hiddenFieldgoogleMapURLOverride" style="display:none">{!googleMapURL}</div> <div id="hiddenFieldLatitude" style="display:none">{!latitude}</div> <div id="hiddenFieldLongitude" style="display:none">{!longitude}</div> <script type="text/javascript"> var safeAddress = document.getElementById('hiddenFieldAddress').innerHTML.replace(/\s+/g, ' '); var safelatitude = document.getElementById('hiddenFieldLatitude').innerHTML.replace(/\s+/g, ' '); var safelongitude = document.getElementById('hiddenFieldLongitude').innerHTML.replace(/\s+/g, ' '); var safeLocalAddressFound = document.getElementById('hiddenFieldLocalAddressFound').innerHTML.replace(/\s+/g, ' '); var safeLocalAddressNotFound = document.getElementById('hiddenFieldLocalAddressNotFound').innerHTML.replace(/\s+/g, ' '); var safeLocalShowMap = document.getElementById('hiddenFieldLocalShowMap').innerHTML.replace(/\s+/g, ' '); var safeErrorHeader = document.getElementById('hiddenFieldErrorHeader').innerHTML.replace(/\s+/g, ' '); var safeErrorDetails = document.getElementById('hiddenFieldErrorDetails').innerHTML.replace(/\s+/g, ' '); var safeErrorWebsite = document.getElementById('hiddenFieldErrorWebsite').innerHTML.replace(/\s+/g, ' '); var safeGoogleLanguageCode = document.getElementById('hiddenFieldGoogleLanguageCode').innerHTML.replace(/\s+/g, ' '); </script> <script type="text/javascript"> // see if Google api URL override has been set var safeGoogleMapURL = document.getElementById('hiddenFieldgoogleMapURL').innerHTML.replace(/\s+/g, ' '); var safeGoogleMapURLOverride = document.getElementById('hiddenFieldgoogleMapURLOverride').innerHTML.replace(/\s+/g, ' '); if (safeGoogleMapURLOverride != "") { safeGoogleMapURL = safeGoogleMapURLOverride; } //change google api document.write('<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&aLoc={!latitude}&zLoc={!longitude}&key=ABQIAAAAqxV-CxuhXx_fdbYnCi75TxSwuLiTNBOhuAjJ8jE06OTy4MFh9BS9pLQLodvQx9Odv8UPA6g4H7Y6Aw"><\/scr' + 'ipt>'); </script> <script src="{!URLFOR($Resource.GoogleMapsInternational, 'googleMapsInternational.js')}" type="text/javascript"></script> <script type="text/javascript"> // run initialize initialize( safelatitude, '{!latitude}', safelongitude , '{!longitude}', '{!iconColour}', safeGoogleMapURL, '{!width}', '{!height}', safeGoogleLanguageCode, safeLocalAddressFound, safeLocalAddressNotFound, safeLocalShowMap, safeErrorHeader, safeErrorDetails, safeErrorWebsite, '{!$Component.map_canvas}' ); </script> </apex:component>
Thank you.
- maiyaku
- April 26, 2012
- Like
- 0
Error Deployment
Failure Message: "System.QueryException: unexpected token: '('", Failure Stack Trace: "Class.BDAPP.QueryRelationShip: line 173, column 1 Class.BDAPP.RunBDAPP: line 63, column 1 Class.BDAPP.execute: line 21, column 1"
Start Line 163 and End Line 173
WhereCondition = 'ID In(' + RelationshipQueRy + ')'; Query = 'Select ID, Contact_ID__c, Account_ID__c, Rev_Contact_ID__c,Rev_Account_ID__c,Rev_Account_ID__r.Loyalty__c,Rev_Account_ID__r.CustomerPriority__c,Rev_Contact_ID__r.Account_Number__c,Rev_Account_ID__r.List_Office__c, '; Query += 'Contact_ID__r.name, Rev_Contact_ID__r.name, Account_ID__r.name, Rev_Account_ID__r.Name,Rev_Account_ID__r.BP_Type__c,Position__c,Relationship_Category__r.name,Rev_Contact_ID__r.AccountMarkDelStatus__c, '; Query += 'Position_Group__c,Contact_ID__r.AccountId,Rev_Account_ID__r.AccountNumber,Contact_ID__r.Phone,Contact_ID__r.MobilePhone,Relationship_Category__r.Relation_to_Owner_TH__c,Rev_Account_ID__r.List_Sales_Rep__c,Rev_Account_ID__r.List_District__c, '; Query += 'Contact_ID__r.Sex__c,Rev_Contact_ID__r.Sex__c,Relationship_Category__r.Reverse_Relationship_Category__r.name,Rev_Contact_ID__r.AccountID,Rev_Contact_ID__r.Account_Name__c,Rev_Account_ID__r.Mark_for_Delete__c '; Query += 'FROM Relationship__c '; Query += 'Where ' + WhereCondition; List<sObject> SRelation = Database.Query(Query);
Thank you so much.
- maiyaku
- April 01, 2012
- Like
- 0
Database Query this error unexpected token
caused by: System.QueryException: unexpected token: '('
Public MD_Sales_Group_Initials__c getMSGI(List<ID> SalesRepName){ String MSGIQuery = ''; List<MD_Sales_Group_Initials__c> lstMSGI = New List<MD_Sales_Group_Initials__c> (); MD_Sales_Group_Initials__c MSGI = New MD_Sales_Group_Initials__c (); MSGIQuery = 'Select id,Name,Code__c From MD_Sales_Group_Initials__c Where ID In (' + SalesRepName + ')'; List<sObject> Qmsgi = Database.Query(MSGIQuery); if(Qmsgi != null && Qmsgi.size()>0){ for(sObject s: Qmsgi){ lstMSGI.add((MD_Sales_Group_Initials__c)s); } } if(lstMSGI != null && lstMSGI.size() > 0){ MSGI = lstMSGI[0]; } Return MSGI; }
MSGIQuery = 'Select id,Name,Code__c From MD_Sales_Group_Initials__c Where ID In (' + SalesRepName + ')';
Thank you.
- maiyaku
- March 08, 2012
- Like
- 0
Use Value in Static Resource put in VF Page Google Maps
<table>
<tr><td>Street:</td><td width="61%" id="AccountStreet"></td></tr>
^ Static Resource Value
<tr><td>City:</td><td width="61%" id="AccountCity"></td></tr>
<tr><td>State/Province:</td><td width="61%" id="AccountSP"></td></tr>
<tr><td>Zip/Postal Code:</td><td width="61%" id="AccountZP"></td></tr>
<tr><td>Country:</td><td width="61%" id="AccountCountry"></td></tr>
<tr><br></br></tr>
</table>
<table>
<tr><td>Phone:</td><td width="47%" id="AccountPhone"></td></tr>
<tr><td>Website:</td><td width="47%" id="AccountWebsite"></td></tr>
<tr><br></br></tr>
</table>
<table>
<p></p>
<c:GoogleMapsInternational iconColour="#236FBD"
width="700"
height="700"
backgroundColour="#FFFFFF"
address="{!Acc.Street__c} {!Acc.City__c} {!Acc.State_Province__c}
^Put to address value for google map
{!Acc.Zip_Postal_Code__c} {!Acc.Country__c}" /> </table>
I can take the Static Resource Value put in address value ? Help me about this.
Thank you so much.
- maiyaku
- January 16, 2012
- Like
- 0
Page is not show list data in html 5
I'm fairly new to using html 5 Please advise.
The first query is object Account it work. but secord query is object Opportunity is not work, page is not show list opportunity.
I think it would be wrong to this Static Resources. this code all
Interface
Customer Visit is work and Order View not show list when cilck.
When click Order View
this code
global with sharing class AccountController { information @RemoteAction global static List<Account> queryAlbums() { return [SELECT Id,Name,Customer_Number__c,Business__c,Pay_Type__c,Term__c,Phone,Website, Street__c, State_Province__c, Zip_Postal_Code__c, Country__c, City__c FROM Account Where Customer_Number__c != null LIMIT 5]; } @RemoteAction global static List<Opportunity> queryOpp() { return [SELECT Id,Name, OrderNumber__c, Amount,StageName, MainCompetitors__c,Probability,AccountID,TrackingNumber__c,CurrentGenerators__c FROM Opportunity]; } }
and static Resources
var currentAlbums = new Array(); var currentOpp = new Array(); var $j = jQuery.noConflict(); $j(document).ready(function() { if(window.location.href.indexOf('#') > 0) { window.location.href = window.location.href.split("#")[0]; } addPageListeners(); getAlbums(function(){ $j.mobile.hidePageLoadingMsg(); }); }); function addPageListeners() { $j('#addalbum').live('pagebeforeshow', function () { $j("#albumNameTxt").val(''); }); $j('#addOpportunity').live('pagebeforeshow', function () { $j("#OppNameTxt").val(''); }); $j('#addtrack').live('pagebeforeshow', function () { $j("#trackNameTxt").val(''); $j("#trackPriceTxt").val(0.00); }); } function getAlbums(callback) { $j('#albumlist').empty(); AccountController.queryAlbums(function(records, e) { showAlbums(records, callback) }, {escape:true}); } function showAlbums(records, callback) { currentAlbums.length = 0; for(var i = 0; i < records.length; i++) { currentAlbums[records[i].Id] = records[i]; } var x = 0; $j.each(records, function() { $j('<li></li>') .attr('id',this.Id) .hide() .append('<h2>' + this.Name + '</h2>') .click(function(e) { e.preventDefault(); $j.mobile.showPageLoadingMsg(); $j('#AlbumName').html(currentAlbums[this.id].Name); $j('#AlbumNumber').html(currentAlbums[this.id].Customer_Number__c); $j('#AccountBusiness').html(currentAlbums[this.id].Business__c); $j('#AccountPayType').html(currentAlbums[this.id].Pay_Type__c); $j('#AccountTerm').html(currentAlbums[this.id].Term__c); $j('#AccountPhone').html(currentAlbums[this.id].Phone); $j('#AccountWebsite').html(currentAlbums[this.id].Website); $j('#AccountStreet').html(currentAlbums[this.id].Street__c); $j('#AccountSP').html(currentAlbums[this.id].State_Province__c); $j('#AccountZP').html(currentAlbums[this.id].Zip_Postal_Code__c); $j('#AccountCountry').html(currentAlbums[this.id].Country__c); $j('#AccountCity').html(currentAlbums[this.id].City__c); }) .appendTo('#albumlist') .show(); x++; }); $j('#albumlist').listview('refresh'); if(callback != null) { callback(); } } //this start not work function getOpps(callback) { $j('#Oppslist').empty(); AccountController.queryOpp(function(records, e) { showOpps(records, callback) }, {escape:true}); } function showOpps(records, callback) { currentOpp.length = 0; for(var i = 0; i < records.length; i++) { currentOpp[records[i].Id] = records[i]; } var x = 0; $j.each(records, function() { $j('<li></li>') .attr('id',this.Id) .hide() .append('<h2>' + this.Name + '</h2>') .click(function(e) { e.preventDefault(); $j.mobile.showPageLoadingMsg(); $j('#OppName').html(currentOpp[this.id].Name); }) .appendTo('#Oppslist') .show(); x++; }); $j('#Oppslist').listview('refresh'); if(callback != null) { callback(); } }
this VF Page
<apex:page showHeader="false" standardStylesheets="false" cache="true" controller="AccountController" > <apex:outputText escape="false" value="{!'<!DOCTYPE html>'}"/> <html> <head> <title>MarketingApp</title> <link rel="stylesheet" href="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.mobile-1.0rc2.min.css')}" /> <script type="text/javascript" src="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.min.js')}"></script> <script type="text/javascript" src="{!URLFOR($Resource.cloudtunes_jQuery, 'jquery.mobile-1.0rc2.min.js')}"></script> <script type="text/javascript" src="{!URLFOR($Resource.MarketingApp)}"></script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> </head> <body> <div data-role="page" data-theme="b" id="mainpage"> <div data-role="header"> <a href='#' id="logout" class='ui-btn-left' data-icon='home' >Home</a> <h1>Main Menu</h1> </div> <div data-role="content"> <ul data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b" align="center"> <a href='#detailpage' style="text-decoration:none"><font color="#363636" size="3"><br><dd>Customer Visit</dd></br></font></a> </ul> <ul data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b" align="center"> <a href='#Opppage' style="text-decoration:none"><font color="#363636" size="3"><br><dd>Order View</dd></br></font></a> </ul> </div> </div> <div data-role="page" data-theme="b" id="detailpage"> <div data-role="header"> <a href='#mainpage' id="backAlbum" class='ui-btn-left' data-icon='arrow-l' data-direction="reverse">Home</a> <h1>Customer List</h1> </div> <div data-role="content"> <a href='#trackpage' style="text-decoration:none"><font color="#363636" size="3"> <input type="hidden" id="albumId" /> <ul id="albumlist" data-inset="true" data-role="listview" data-theme="b" data-dividertheme="b"> </ul> </font></a> </div> </div> <div data-role="page" data-theme="b" id="Opppage"> <div data-role="header"> <a href='#mainpage' id="backAlbum" class='ui-btn-left' data-icon='arrow-l' data-direction="reverse">Home</a> <h1>Order List</h1> </div> <input type="hidden" id="OppId" /> <ul id="Oppslist" data-inset="true" data-role="listview" data-theme="c" data-dividertheme="a"> </ul> </div> </body> </html> </apex:page>
thank you very much.
- maiyaku
- January 12, 2012
- Like
- 0
For Loop not work in Test Class
Coverage 8% - -
Test Class is not work a red zone area
1 Public Class Tomoring { 2 3 public static void CreateTomoring() { 4 5 Integer EHODaybyMonth = 0; 6 Integer i; 7 8 DateTime DateNow = System.now(); 9 10 List<Time_Attendance__c> lstTA = [Select id,Agent_Name__c,Check_in__c,Check_out__c,RecordFinish__c,Time_Calculate__c from 11Time_Attendance__c Where Check_out__c = null]; 12 13 if((DateNow.Hour() + DateNow.Minute()) == 0){ 14 15** for(Time_Attendance__c TA : lstTA){ TA.Check_out__c = System.now() - 1; update TA; Time_Attendance__c TAC = new Time_Attendance__c (); TAC.Check_in__c = System.Now(); DateTime Ci = TAC.Check_in__c ; DateTime Co = TAC.Check_Out__c ; TAC.Name = TA.Agent_Name__c + ' ' + Co.Day() + '/' + Co.Month() + '/' + Co.Year() + ' ' + Co.Hour() + ':' + Co.Minute(); TAC.RecordFinish__c = True; Double D,M,Y,H,MN = 0; if(Ci.Minute() > Co.Minute()){ if(Ci.Day() > Co.Day()){ if(Ci.Month() > Co.Month()){ Integer CalMonth = Co.Month() - Ci.Month(); Integer CalDay = Ci.Month(); for(i = Ci.Month();i < Co.Month();i++){ IF(i == 1){ EHODaybyMonth = 31*24;} Else IF(i == 2){ EHODaybyMonth = 28*24;} Else IF(i == 3){ EHODaybyMonth = 31*24;} Else IF(i == 4){ EHODaybyMonth = 30*24;} Else IF(i == 5){ EHODaybyMonth = 31*24;} Else IF(i == 6){ EHODaybyMonth = 30*24;} Else IF(i == 7){ EHODaybyMonth = 31*24;} Else IF(i == 8){ EHODaybyMonth = 31*24;} Else IF(i == 9){ EHODaybyMonth = 30*24;} Else IF(i == 10){ EHODaybyMonth = 31*24;} Else IF(i == 11){ EHODaybyMonth = 30*24;} Else IF(i == 12){ EHODaybyMonth = 31*24;} CalDay = CalDay + EHODaybyMonth ; } D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D + CalDay) - 1; MN = ((Co.Minute() + 60) - Ci.Minute()); } Else{ //CoMonth less than CiDay D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D) - 1; MN = ((Co.Minute() + 60) - Ci.Minute()); } } Else{ //CoDay less than CiDay if(Co.Month() > Ci.Month()){ H = ((Co.Hour() - Ci.Hour()) ) - 1; MN = ((Co.Minute() + 60) - Ci.Minute()); } } } Else{ if(Co.Day() > Ci.Day()){ if(Co.Month() > Ci.Month()){ Integer CalMonth = Co.Month() - Ci.Month(); Integer CalDay = Ci.Month(); for(i = Ci.Month();i < Co.Month();i++){ IF(i == 1){ EHODaybyMonth = 31*24;} Else IF(i == 2){ EHODaybyMonth = 28*24;} Else IF(i == 3){ EHODaybyMonth = 31*24;} Else IF(i == 4){ EHODaybyMonth = 30*24;} Else IF(i == 5){ EHODaybyMonth = 31*24;} Else IF(i == 6){ EHODaybyMonth = 30*24;} Else IF(i == 7){ EHODaybyMonth = 31*24;} Else IF(i == 8){ EHODaybyMonth = 31*24;} Else IF(i == 9){ EHODaybyMonth = 30*24;} Else IF(i == 10){ EHODaybyMonth = 31*24;} Else IF(i == 11){ EHODaybyMonth = 30*24;} Else IF(i == 12){ EHODaybyMonth = 31*24;} CalDay = CalDay + EHODaybyMonth ; } D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D + CalDay); MN = (Co.Minute() - Ci.Minute()) ; //System.AssertEquals('','Else ' + D + ': ' + M); } Else{ D = (Co.Day() - Ci.Day()) * 24; H = ((Co.Hour() - Ci.Hour()) + D); MN = (Co.Minute() - Ci.Minute()) ; } } Else{ H = ((Co.Hour() - Ci.Hour())); MN = (Co.Minute() - Ci.Minute()) ; } } TAC.Time_Calculate__c = H+(MN/100); insert TAC; } } }
this Line 15 more is a red zone not work
Static testmethod void TestTomoring () { CreateTomoring(); Profile p = [select id from profile where name = 'System Administrator']; User Ua = New User(); Ua.Assignment_Group_Active__c = True; Ua.CountClick__c = 2; Ua.EditbySup__c = False; Ua.profileid = p.Id; Ua.Username = 'Test@sccc.co.th'; Ua.FirstName = 'hello'; Ua.LastName = 'Test'; Ua.Email = 'Test@sccc.co.th'; Ua.Alias = 'HTA'; Ua.isActive = true; Ua.emailencodingkey='UTF-8'; Ua.timezonesidkey='America/Los_Angeles'; Ua.CommunityNickname = 'OKTEST'; Ua.localesidkey='en_US'; Ua.languagelocalekey='en_US'; insert Ua; Time_Attendance__c TAC = New Time_Attendance__c(); TAC.Check_in__c = System.Now(); TAC.Name = 'Test' + System.Now(); TAC.RecordFinish__c = True; TAC.Time_Calculate__c = 12.3; insert TAC; TAC.Check_out__c = System.now() - 1; Update TAC; List<Time_Attendance__c> lstTA = [Select id,Agent_Name__c,Check_in__c,Check_out__c,RecordFinish__c,Time_Calculate__c from Time_Attendance__c Where Check_out__c = null]; for(Time_Attendance__c TA : lstTA){ TA.Check_out__c = System.now() - 1; Update TA; Time_Attendance__c TAC1 = New Time_Attendance__c(); TAC1.Check_in__c = System.Now(); TAC1.Name = 'Test' + System.Now(); TAC1.RecordFinish__c = True; TAC1.Time_Calculate__c = 12.3; insert TAC1; } } }
Thank you.
Happy new year !
- maiyaku
- December 27, 2011
- Like
- 0
Constructor not defined in Test Class
Class is use override view record. I can open but Test Class not work !
public class genMembershipConditionsPDF{ public genMembershipConditionsPDF(ApexPages.StandardController controller) { gotoPDFPage(); } public Pagereference gotoPDFPage() { return new Pagereference('/apex/MembershipConditionsPDF?Id='+Apexpages.Currentpage().getParameters().get('Id')); } }
@isTest private class test_genMembershipConditionsPDF { static testMethod void myUnitTest() { Account Acc = new Account(); Acc.name = 'Test'; insert Acc; Membership_Conditions__c MC = new Membership_Conditions__c(); MC.Copy_of_organisational_structure__c = True; MC.OrganizationsID__c = Acc.id; MC.Designation__c = 'Test'; insert MC; ApexPages.StandardSetController controller = new ApexPages.StandardSetController(MC); genMembershipConditionsPDF sc = new genMembershipConditionsPDF(); PageReference S = sc.gotoPDFPage(); } }
Thank you so much.
- maiyaku
- November 24, 2011
- Like
- 0
Alert Popup in page not work
I want check country account this page is match country visited object. But it not work not show when click save
public PageReference save() { Account AccS = [Select id,Country__c from Account Where id =: objCus[0].AccountID__c]; String CountryName = Accs.Country__c; Boolean CheckCountry = False; List<Country_Visited__c> lstCRV = [Select id,Name from Country_Visited__c Where Customer_Visit_ReportID__c =: objCus[0].Customer_Visit_ReportID__c]; for(Country_Visited__c CRV : lstCRV){ if(CRV.Name == CountryName){ CheckCountry = True; } } if(CheckCountry == True){ if(objCus.size()>0) { CountryVisited(); List<Customer_Visited__c > lstCV = [Select id from Customer_Visited__c Where AccountID__c =: objCus[0].AccountID__c]; objCus[0].Nums__c = lstCV.size(); insert objCus; CusID = objCus[0].id; } insertExistingProduct(); insertNewProduct(); insertTask(); CreateOpportunity(); return Cancel(); } showmessage = 'True'; return null; } public string showmessage { get;set; }
Page
<apex:pageBlock id="pageBlock" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}" rerender="error" onclick="showmsg()"/> <apex:commandButton value="Cancel" action="{!Cancel}" rerender="error"/> </apex:pageBlockButtons> </apex:pageBlock> <script> function showmsg(){ if('{!showMessage}'=='True'){ alert('your message!'); return false; } } </script>
Thank so much.
- maiyaku
- November 14, 2011
- Like
- 0
Test Class not work
it's not work 2 line
hilight a line not work in the Trigger
setAccountNumber.add(myNewCon .Account_Number__c) ;
myNewCon.AccountID = Acc.id;
@isTest private class TestUpdateAccountNameAndNumberinContact{ static testMethod void myUnitPopContact() { Account Acc = new Account(Name = 'test',AccountNumber = '0000001'); insert Acc; Account Acc2 = new Account(Name = 'test2',AccountNumber = '0000001'); insert Acc2; Test.StartTest(); Contact Con = new Contact(); ApexPages.currentPage().getParameters().put('id',con.id); Con.LastName = 'test2'; Con.AccountID = Acc.id; Con.Account_Number__c = Acc.AccountNumber; insert con; try{ update con; }catch(DMLException de){} Contact Dup = new Contact(); Dup.LastName = 'test'; Dup.AccountID = Acc2.id; Dup.Account_Number__c = Con.Account_Number__c ; insert Dup; try{ update Dup; }catch(DMLException de){} Test.StopTest(); } }
trigger UpdateAccountNameAndNumberinContact on Contact (before Update){ //List<Account> Acc = new List<Account>(); Set<String> setAccountNumber = new Set<String>(); Set<String> setAccount = new Set<String>(); for(Contact Con : Trigger.new){ Map<Id,Contact> newConMap = Trigger.newMap; Map<Id,Contact> oldConMap = Trigger.oldMap; for(Id ConId:newConMap.keySet()){ Contact myNewCon = newConMap.get(ConId); Contact myOldCon = oldConMap.get(ConId); if(myNewCon.AccountID == myOldCon.AccountID && myNewCon.Account_Number__c <> myOldCon.Account_Number__c && myNewCon.Account_Number__c != null){ setAccountNumber.add(myNewCon .Account_Number__c) ; } else if(myNewCon.AccountID <> myOldCon.AccountID && myNewCon.Account_Number__c == myOldCon.Account_Number__c && myNewCon.AccountID != null){ setAccount.add(myNewCon .AccountID ) ; } } } Account Acc = new Account(); List<Account> lstAcc = [Select id,AccountNumber from Account Where AccountNumber in : setAccountNumber or id in : setAccount]; if(lstAcc.size()>0) { Acc = lstAcc[0]; } for(Contact Con : Trigger.new){ Map<Id,Contact> newConMap = Trigger.newMap; Map<Id,Contact> oldConMap = Trigger.oldMap; for(Id ConId:newConMap.keySet()){ Contact myNewCon = newConMap.get(ConId); Contact myOldCon = oldConMap.get(ConId); if(myNewCon.AccountID == myOldCon.AccountID && myNewCon.Account_Number__c <> myOldCon.Account_Number__c && myNewCon.Account_Number__c != null){ myNewCon.AccountID = Acc.id; } else if(myNewCon.AccountID <> myOldCon.AccountID && myNewCon.Account_Number__c == myOldCon.Account_Number__c && myNewCon.AccountID != null){ myNewCon.Account_Number__c = Acc.AccountNumber; } /*else if(myNewCon.AccountID <> myOldCon.AccountID && myNewCon.Account_Number__c <> myOldCon.Account_Number__c && myNewCon.AccountID != null && myNewCon.Account_Number__c != null){ myNewCon.AccountID.AddError('Mismatch Account Name and Account Number'); myNewCon.Account_Number__c.AddError('Mismatch Account Name and Account Number'); }*/ } } }
Thank you so much
- Kyo
- July 29, 2011
- Like
- 0
Update CodeCoverage in TestClass
Test Class is not full loop . it's problem 1 line in Testclass
Coverage is 85% now
trigger ChangeStatusinOBC on Out_Bound_Call_List__c (Before insert,Before Update) { // You can change status equal Complete when RelatedList OB Contact status all Complete set<ID> setOBLID = new set<ID>(); for(Out_Bound_Call_List__c OBL : Trigger.new){ setOBLID.Add(OBL.ID); } // Add id for Query List<OutBound_Contact__c> lstOBC = [Select id from OutBound_Contact__c where Out_Bound_Call_List__c in : setOBLID]; // Query OutBound Contact List System.debug('Error SOQL'); for(Out_Bound_Call_List__c OBL : Trigger.new){ if((lstOBC.size() != OBL.Count_Complete__c) && lstOBC.size() != 0 && OBL.Status__c == 'Completed'){ Trigger.new[0].Status__c.AddError('Status in OutBound Contact all not equal to contacted'); }// Set Error in Field Status } }
a problem line :
if((lstOBC.size() != OBL.Count_Complete__c) && lstOBC.size() != 0 && OBL.Status__c == 'Completed'){
@isTest private class TestChangeStatusinOBC { static testMethod void myTest() { Out_Bound_Call_List__c OBL = new Out_Bound_Call_List__c(); OBL.Name = 'Test'; insert OBL; OutBound_Contact__c OBC = new OutBound_Contact__c(); OBC.Out_Bound_Call_List__c = OBL.id; OBC.Status__c = 'Contacted'; insert OBC; update OBC; Out_Bound_Call_List__c OBL1 = new Out_Bound_Call_List__c(); OBL.Name = 'Test'; OBL.Status__c = 'Completed'; test.startTest(); Try{ insert OBL; update OBL; } catch (Exception e) { System.Debug('Status in OutBound Contact all not equal to contacted'); } test.stopTest(); } }
Thank you so much.
- Kyo
- July 28, 2011
- Like
- 0
Error List has no rows
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SumSodcSync: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.SumSodcSync: line 4, column 31: []
trigger SumSodcSync on Sales_Order_Complete__c(After insert) {
for(Sales_Order_Complete__c sodc:trigger.new){
Sales_Order__c Sod = [Select id from Sales_Order__c Where id = : ApexPages.currentPage().getParameters().get('id')];
Sales_Order_Complete__c[] Scom = [Select id,OpportunitiesID__c ,DimensionTxWxL__c,Grade__c,Total_Weight__c,Quotes__c,
Fail__c, Name, Products__c, Quantity__c,Quantity_Remain__c,Sales_OrderID__c,Success__c,Date__c,Pop__c,
Sales_Order_Line_ItemID__c,Deliver_Remain__c,Delivery_Good_Pcs__c,Order_Quantity__c,Total_Finished_Good__c ,
Delivery_Good_Ton__c,Delivery_Remain_Ton__c,Finished_Good_Remain__c,Finished_Good_Remain_Ton__c,Finished_Tons__c
from Sales_Order_Complete__c where Sales_OrderID__c =: sod.id And Pop__c != true ];
Sodc_Sumary__c[] objssc = new Sodc_Sumary__c[]{};
Sodc_Sumary__c Sc = new Sodc_Sumary__c();
for(Sales_Order_Complete__c Ssc: Scom ){
Sc = new Sodc_Sumary__c();
Sc.Sales_Order__c = Ssc.Sales_OrderID__c;
Sc.Dimen__c = Ssc.DimensionTxWxL__c;
Sc.Grade__c = Ssc.Grade__c;
Sc.Order_Status__c = Ssc.Id;
Sc.Name = Ssc.Name;
Sc.Finished_Good_Remain__c = Ssc.Finished_Good_Remain__c;
Sc.Finished_Good_Remain_Ton__c = Ssc.Finished_Good_Remain_Ton__c;
Sc.Deliver_Remain__c= Ssc.Deliver_Remain__c;
Sc.Delivery_Remain_Ton__c = Ssc.Delivery_Remain_Ton__c;
Sc.Quantity__c = Ssc.Order_Quantity__c;
objssc.add(Sc);
}
insert objssc;
}
}
Please guide me or sample
Thank you so much
- maiyaku
- May 25, 2011
- Like
- 0
System Limit 101
System.LimitException: Too many SOQL queries: 101
Trigger.UpdateQLine: line 4, column 44
trigger UpdateQLine on Quotes_Line_Item__c (after update) { for(Quotes_Line_Item__c QL:trigger.new){ if(QL.isClosed__c == false){ Opportunities_Line_Item__c[] OPL = [Select Id ,UP1__c,Quantity__c from Opportunities_Line_Item__c Where Id =: QL.Opportunities_Line_Item__c Limit 1000]; for(Opportunities_Line_Item__c OL:OPL){ OL.Quantity__c = QL.Quantity__c; OL.UP1__c = QL.Unit_Price_For__c; } update OPL; } } }
- Kyo
- May 16, 2011
- Like
- 0