-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
18Questions
-
18Replies
Help on trigger to create the total of transactions
Hi
I have two objects here
1)Transactions
2)Achieved
I have a field on Transactions named Amount
and a field on Achieved name Total Value
If a user does 7 transactions in a financial year , I want the total of the 7 transaction object Amount field to add up to the Total Value field on Achieved object.
If the user deletes the transaction, the Total value field should be deducted also.
Financial year is 1 Jan 2012 - 31 DEC 2012. The transaction should be decided based on the created date.
Please help me on this
Thanks
-
- phantom1982
- April 18, 2012
- Like
- 0
- Continue reading or reply
Account Ownership Changed
Is there any way that the system can be set so the original account owner remains on the sharing when changed to another user?
Elaborating on this
If we change the ownership of an account from Owner A to Owner B, the ownership goes to Owner B
Is there any way where we could have the Owner A in the account sharing list automatically when we change the ownership?
Can anyone help me please.
Thanks
-
- phantom1982
- April 10, 2012
- Like
- 0
- Continue reading or reply
Conveyance Case Comment within 48 hrs of case creation
Hi
I need a help regarding an issue please.
When a case has been created and if there is no case comment on the case within 48 hours of the case creation time,an email alert should be sent to the owner of the case.
Is it possible to do so?
Can anyone help me with this please
Kind regards
-
- phantom1982
- March 14, 2012
- Like
- 0
- Continue reading or reply
Open Activity Count on Accounts
Hi
I have a custom field which is Open Activity Count.
I want to have the count of all the tasks that are open on the account to appear on the field.
For example if I create an account , automatically 3 tasks get created. I want the number 3 to appear automatically on the Open Activity Count field.
If I create another account record type, then 4 tasks may get created automatically.
If I manually create a task from the Open Activities related list, then also the number should appear in the Open Activity Count field.
I want the count of all the tasks in the open activities related list which have been created automatically(i.e by a workflow rule, trigger etc) or manually(i.e. by creating it on the open activities related list ) to appear in the Open Activity Count field.
If I close the task then the count should get deducted.
Can anyone please help me with this.
Thanks in advance
-
- phantom1982
- March 05, 2012
- Like
- 0
- Continue reading or reply
Determine the Object Type
How would you determine what object is associated with an event. The Related To field on Events object is a drop down of Objects so how can one determine the selected object at runtime?
Thanks
-
- phantom1982
- October 31, 2011
- Like
- 0
- Continue reading or reply
Hiding Event Details
A quick question, is it possible to hide Event details (like related account/ contact) while the sharing on account is public?
Thanks
-
- phantom1982
- October 13, 2011
- Like
- 0
- Continue reading or reply
Hiding Event Details
A quick question, is it possible to hide Event details (like related account/ contact) while the sharing on account is public?
Thanks
-
- phantom1982
- October 12, 2011
- Like
- 0
- Continue reading or reply
Constructing a URL with Parameters
Hi,
I have to implement a salesforce to SMS function where user will be able to send an sms from salesforce to client. I am facing a bit of challenge in constructing the URL with parameters in it, that is sent to the SMS service. The SMS text is formatted in a sense that it ends with the Sender Name, Mobile and Company Name e.g:
_____________________
This is the test SMS Text
Sender Name
Mobile Phone
Company
____________________
The problem is in the characters used for formatting the text \n and \r. Below is the code:
public PageReference sendSMS(){ User u = [select FirstName, LastName, MobilePhone from User where Username =: UserInfo.getUserName()]; SMS__c sms = [select SMS_Text__c, Account__c from SMS__c where id = :ApexPages.currentPage().getParameters().get('id')]; Account acc = [Select Phone from Account where Id = :sms.Account__c]; String smstext = sms.SMS_Text__c+'\n\n'+u.FirstName+' '+u.LastName+'\n'+u.MobilePhone+'\nCyber Consultants'; //sms.SMS_Text__c = smstext; //insert sms; String myurl = 'http://mytestcompany.com/sendurlcomma.asp?user=200335466&pwd=jn23e52&senderid=ABC&mobileno='+acc.Phone+'&msgtext='+smstext+'&priority=High&CountryCode=+971'; PageReference mypage = new PageReference(myurl); mypage.setRedirect(true); return myPage; }
Pleas if anyone can lead me to the right direction in generating the proper URL.
-
- phantom1982
- August 09, 2011
- Like
- 0
- Continue reading or reply
Invalid Foreign Key Relationship Error
Hi,
I am writing a trigger on account object. Whenever a flag is updated in accounts, trigger updates the corresponding Owner in the User object. Follwing is the code:
trigger ServiceBreachTrigger on Account (after update) { for(Account a: trigger.new){ if(a.service.breach__c == true){ user u = [Select Id,times_service_breached__c from User where Id = :a.OwnerId LIMIT 1]; a.Service_Breach__c = false; if(u.times_service_breached__c == 0){ u.times_service_breached__c = 1; u.times_service_breached__c++; } u.times_service_breached__c++; update a; update u; } } }
I am getting referential integrity error which specifically states:
Invalid Foreign Key Relationship: Account .Service at line (a.Service_Breach__c = false;)
Any help?
Thanks
-
- phantom1982
- June 26, 2011
- Like
- 0
- Continue reading or reply
Trigger Problem
Hi,
I wrote a trigger that serves to update a custom field on an object. The field actually gets updated with the change in price of the item. Now am kind of stuck with it if I use the before update trigger, it shows the second last change in the price. I cannot use the After update as record gets locked and I cannot update the field value. Below is the trigger code:
trigger TrackPRICEupdate on pb__InventoryItem__c(before update) { pb__InventoryItem__History invh = new pb__InventoryItem__History(); for(pb__InventoryItem__c inv: trigger.new){ invh = [Select NEWVALUE, FIELD, OLDVALUE, CREATEDDATE, PARENTID from pb__InventoryItem__History where PARENTID = :inv.id and FIELD = 'pb__PurchaseListPrice__c' order by CREATEDDATE DESC LIMIT 1]; if(invh.oldvalue <> null && invh.newvalue <> null) { string a = string.valueof(invh.oldvalue); string b = string.valueof(invh.newvalue); decimal old = decimal.valueof(a); decimal newv = decimal.valueof(b); inv.price_change__c = newv - old; } //update inv; } }
Anyone can help?
-
- phantom1982
- June 20, 2011
- Like
- 0
- Continue reading or reply
Scope of variable in a Controller class
Can someone please explian the following?
Public Class AController{
Public AController(){}
Private boolean a = false;
Public firstupdatea{
this.a = true;
}
// this is called from the VF page in an action tag.
Public PageReference updatea(){
if (this.a == true){
// further actions..
}
}
}
Can someone please tell if the boolean a will retain the value (set to true) in the firstupdatea() function, when checked in the if condition in updatea()? if not? why and how can to make it work so it retains the value..
Thanks
-
- phantom1982
- April 12, 2011
- Like
- 0
- Continue reading or reply
Updating a custom object
Can someone please explain the standard way to update a custom object from an APEX class?
Thanks
-
- phantom1982
- April 10, 2011
- Like
- 0
- Continue reading or reply
Time based workflows problem
Guys,
I am working on creating a time based workflow to notify the admin of the persons birthday. If i use the evaluation criteria = When a record is created, or when a record is edited and did not previously meet the rule criteria. Should the workflow update all the existing records if they are edited?
-
- phantom1982
- March 16, 2011
- Like
- 0
- Continue reading or reply
Simple question
Hi Code Gurus,
Can someone plesae tell if we can use a List of standard objects with all its available methods like size() etc in a constructor?
this.email_c = parameters.get('PersonEmail'); this.dup = [SELECT id from Account WHERE PersonEmail =: email_c]; if(dup.size()>0){ this.duplicatelead = true; }
this code should set the duplicatelead to true everytime there's a duplicate record on the basis of email. But its not happening, the list size stays 0 always. Any idea why?
-
- phantom1982
- March 13, 2011
- Like
- 0
- Continue reading or reply
System.NullPointerException
The below code runs fine in testing environment, it's actually generating a PDF document.
public with sharing class PDFTransactionSlip {
public PDFTransactionSlip() {
}
public PDFTransactionSlip(ApexPages.StandardController controller) {
}
private String getXmlString(pb__Agreement__c c)
{
//datetime todayis = system.now();
double skcomdue = c.Buyer_Agency_Fee__c + c.Seller_Agency_Fee__c;
double premiumseller = c.pb__PurchaseListPrice__c - c.Inventory_Original_Price__c;
String s = '<?xml version="1.0" encoding="UTF-8"?>' +
'<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' +
'<f href="https://na*.salesforce.com/resource/1298882850000/Transaction_Slip"/>' +
'<fields>' +
'<field name="Transaction_Type"><value>' + c.pb__AgreementType__c + '</value></field>' +
'<field name="Buyer_Type"><value>' + c.Buyer_Type__c + '</value></field>' +
'<field name="Buyer_Name"><value>' +c.Buyer_Name__c + '</value></field>' +
'<field name="Buyer_No"><value>' + c.Buyer_Phone_No__c + '</value></field>' +
'<field name="Buyer_Address"><value>' + c.Buyer_Address__c + '</value></field>' +
'<field name="Buyer_Pasport"><value>' + c.Buyer_Passport_No__c+ '</value></field>' +
'<field name="Buyer_Nationality"><value>' + c.pb__AccountRegistrationCountry__c + '</value></field>' +
'<field name="Seller_Type"><value>' + c.Seller_Type__c + '</value></field>' +
'<field name="Seller_Name"><value>' + c.pb__SellerFullName__c + '</value></field>' +
'<field name="Seller_No"><value>' + c.seller_Phone_no__c + '</value></field>' +
'<field name="Seller_Address"><value>' + c.Seller_Address__c + '</value></field>' +
'<field name="Seller_Pasport"><value>' + c.Seller_Passport_No__c + '</value></field>' +
'<field name="Seller_Nationality"><value>' + c.Seller_Country__c + '</value></field>' +
'<field name="Developer"><value>' + c.pb__DeveloperRegistrationNumber__c + '</value></field>' +
'<field name="PSA Date"><value>' + c.pb__AgreementDate__c + '</value></field>' +
'<field name="Unit_Details"><value>' + c.pb__UnitName__c + '</value></field>' +
'<field name="No_Of_Bedrooms"><value>' + c.pb__UnitBedrooms__c + '</value></field>' +
'<field name="Sqft"><value>' + c.pb__TotalAreaSqft__c + '</value></field>' +
'<field name="Built_Up"><value>' + c.pb__TotalAreaSqft__c + '</value></field>' +
'<field name="Original_Price"><value>' + c.Inventory_Original_Price__c + '</value></field>' +
'<field name="Net_Purchase_Price"><value>' + c.pb__PurchaseListPrice__c + '</value></field>' +
'<field name="Amount_Paid"><value>' + c.Amount_Paid_on_Property__c + '</value></field>' +
'<field name="Premium_Seller"><value>' + premiumseller + '</value></field>' +
'<field name="Deposit Amount"><value>' + c.Deposit_Amount__c + '</value></field>' +
'<field name="Transfer_Fee"><value>' + c.Transfer_Fee__c + '</value></field>' +
'<field name="Total_Purchase"><value>' + c.Total_Purchase_Price_AED__c + '</value></field>' +
'<field name="Buyer_Agency"><value>' + c.Buyer_Agency_Fee__c + '</value></field>' +
'<field name="Seller_Agency"><value>' + c.Seller_Agency_Fee__c + '</value></field>' +
'<field name="Conveyance_Fees"><value>' + c.Conveyance_Fees__c + '</value></field>' +
'<field name="SK_Commission_Due"><value>' + skcomdue + '</value></field>' +
'<field name="Total_Commission"><value>' + skcomdue+ '</value></field>' +
'</fields><ids original="6CF3C495DE77414F85BC24E6CFC3F692" modified="EF5CB2FB7A5BAA4FB634933ADC944031"/>' +
'</xfdf>';
return s;
}
public PageReference XFDFInit()
{
LIST<pb__Agreement__c> c = [Select Agreed_Price__c,pb__AgreementType__c,
pb__AccountRegistrationCountry__c , Amount_Paid_on_Property__c, Buyer_Agency_Fee__c,
Buyer_Conveyance_Fee__c,Buyer_Phone_No__c, Buyer_Address__c, Buyer_Passport_No__c,
Buyer_Type__c, Cheque_Data__c, Conveyance_Fees__c,
Deposit_Amount__c,Buyer_Name__c, Deposit_Status__c, Id, Initial_Term_SKadded__c,
Inventor_Title_No__c, Inventory_Completion_Status__c, Inventory_Original_Price__c,
Landlord_Commision__c, Mortgage_Discharge_Fee__c, Mortgage_Registration_Fee__c,
Name, Net_Achievable_Price_to_Seller1__c, NOC_Fee_to_Developer__c,
Number_of_Cheques_Required__c, pb__AccountId__c, pb__DeveloperId__c,
pb__DeveloperRegistrationNumber__c, pb__DownPaymentsComplete__c,
pb__FeesComplete__c, pb__InventoryId__c, pb__ItemCompletionStatus__c,
pb__OfferId__c,seller_phone_no__c, pb__PurchaseListPrice__c, pb__PurchasePrice__c,
pb__SellerFullName__c, pb__SellerId__c, pb__Status__c, pb__TotalAmount__c,
pb__TotalAreaSqft__c, pb__TotalAreaSqm__c, pb__UnitBedrooms__c,
pb__UnitFloorNumber__c, pb__UnitName__c, pb__UnitType__c,
Seller_Address__c, Seller_Agency_Fee__c, Seller_Conveyance_Fee__c,
Seller_Country__c, pb__AgreementDate__c , Seller_Passport_No__c, Seller_Type__c,
Service_Maintenance_Fee_Pro_rata__c, Tenant_Commission__c,
Title_Deed__c, Total_Purchase_Price_AED__c, Transfer_Date__c,
Transfer_Fee__c, Unit_Number__c from pb__Agreement__c
WHERE id = :ApexPages.currentPage().getParameters().get('id') limit 1];
if(c.size() > 0){
pb__Agreement__c nc = c[0];
String xmlContent = getXmlString(nc);
Attachment attachment = new Attachment();
attachment.Body = Blob.valueOf(xmlContent);
attachment.Name = 'Transaction_Slip_' + c[0].Name + '_' + System.now() + '.XFDF';
attachment.ParentId = c[0].Id;
insert attachment;
PageReference contactPage = new PageReference('/' + c[0].id);
contactPage.setRedirect(true);
return contactPage;
}
PageReference contactPage = new PageReference('/' + ApexPages.currentPage().getParameters().get('id'));
contactPage.setRedirect(true);
return contactPage;
}
}
Problem is when try to execute it in production, it gives the following exception:
System.NullPointerException: Attempt to de-reference a null object
Class.PDFTransactionSlip.getXmlString: line 12, column 26 Class.PDFTransactionSlip.XFDFInit: line 85, column 29 External entry point
-
- phantom1982
- March 02, 2011
- Like
- 0
- Continue reading or reply
Does anyone see a problem with this code?
Hi, am working on a pretty simple code that restricts the Lead duplication.Leads are coming in from web pages, parameters are extracted and checked below if its a duplicate:
// 1. Leads coming in get the parameters extracted.
// 2. Now checking for duplication based on Record type and Email
List <RecordType> R = [SELECT Id from RecordType WHERE SObjectType =: 'Account' AND Name =: r_name]; if(R.size()>0){ LIST <Account>ifdup = [SELECT Id, OwnerId from Account WHERE PersonEmail =: r_email AND RecrodTypeId =: R[0].Id]; if (ifdup.size()>0){ Task tsk = new Task(); tsk.WhoId = ifdup[0].Id; tsk.OwnerId = ifdup[0].OwnerId; tsk.Status = 'Open'; tsk.Priority = 'High'; insert tsk;
duplicateLead = true; exceptionThrown = true; PageReference p = new PageReference(this.fail_page); p.setRedirect(true); return p; }
// 3. Since not a dupliate, account creation.
In case of duplicate lead, code shall return Failure along with task creation for the existing lead owner. But somehow its not working this way, Leads are getting duplicated. My understanding is when the If condition returns the page P, its the end of the code execution.
Can someone help me fix it please? Thanks
-
- phantom1982
- February 20, 2011
- Like
- 0
- Continue reading or reply
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
Hi,
I am trying to create an Event through apex, everything seems fine in the Sandbox but the deployment fails
System.DMLException:Insert Failed. First exception on row 0; First error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UpdateCalendar, Execution of Before Insert.
with the following warning in IDE.
WARN [2011-02-15 14:34:40,447] (DeploymentController.java:deployWork:993) - Deployment FAILED. Got the following deploy messages [3]:
(1) filename = classes/UnitTestsUpdateCalendar.cls, result = SUCCESS, affect = changed, id = 01pA00000023yriIAA, fullname = UnitTestsUpdateCalendar
(2) filename = package.xml, result = SUCCESS, affect = changed, id = null, fullname = package.xml
(3) filename = triggers/UpdateCalendar.trigger, result = SUCCESS, affect = changed, id = 01qA0000000dSiqIAE, fullname = UpdateCalendar
The trigger is below, its basically creating an event using values from another object..
trigger UpdateCalendar on SFDC_PTO_Request__c (before insert) { if (trigger.isInsert){ for(SFDC_PTO_Request__c pto: trigger.new){ Event evt = new Event(); evt.StartDateTime = pto.Request_Start_Date__c; evt.EndDateTime = pto.Request_End_Date__c; evt.Description = 'The user is having a ' + pto.Request_Type__c; //evt.ShowAs = 'Out of Office'; SFDC_Employee__c emp = [Select Name from SFDC_Employee__c WHERE Id =: pto.Employee__c]; User u = [SELECT Id from User WHERE Name =: emp.Name]; evt.OwnerId = u.Id; evt.Subject = pto.Request_Type__c; insert evt; } } }
The test class is below:
@isTest private class UnitTestsUpdateCalendar { static testMethod void myUnitTest() { SFDC_PTO_Request__c pto = new SFDC_PTO_Request__c(); DateTime dT = System.now(); Date myDate = date.newinstance(dT.year(), dT.month(), dT.day()); pto.Request_Start_Date__c = myDate; pto.Request_End_Date__c = myDate; list<SFDC_Employee__c> emp= [Select Id from SFDC_Employee__c where Name =: 'Admin Support Propertybase']; if (emp.size()>0){ pto.Employee__c = emp[0].Id; } insert pto; } }
-
- phantom1982
- February 15, 2011
- Like
- 0
- Continue reading or reply
Help in testing this code
Fellas,
Got this piece of code that needs to be tested, am aware of unit testing to some extent but still a newbie. Can someone help me write/guide simple test class (called by a visual force page) for the code below, greatly appreciated. :)
public class PDFMerger
{
public PDFMerger(ApexPages.StandardController controller) {
}
private String getXmlString(pb__InventoryItem__c c, User u)
{
datetime todayis = system.now();
String s = '<?xml version="1.0" encoding="UTF-8"?>' +
'<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' +
'<f href="https://*****.salesforce.com/resource/1295957476000/Work_Assurance_Inspection"/>' +
'<fields>' +
'<field name="property address"><value>' + c.Unit_No__c + ' ' + c.Project__c + ' '+ c.Area__c + '</value></field>' +
'<field name="agent name"><value>' + u.Name + '</value></field>' +
'<field name="Date"><value>' + todayis + '</value></field>' +
'<field name="Property Type"><value>' + c.pb__UnitType__c + '</value></field>' +
'<field name="Number of Bedrooms"><value>' + c.pb__UnitBedrooms__c + '</value></field>' +
'</fields><ids original="E348711A455B6041A503958ABEF555F0" modified="D4A9F66D55B86D47A4F3991DD9F07E18"/>' +
'</xfdf>';
return s;
}
public PageReference XFDFInit()
{
pb__InventoryItem__c c = [SELECT Id, Ownerid, Name, pb__UnitType__c, pb__UnitBedrooms__c, Unit_No__c, Project__c, Area__c FROM pb__InventoryItem__c
WHERE id = :ApexPages.currentPage().getParameters().get('id')];
User u = [SELECT id, Name FROM User
WHERE id = :c.Ownerid];
String xmlContent = getXmlString(c, u);
Attachment attachment = new Attachment();
attachment.Body = Blob.valueOf(xmlContent);
attachment.Name = c.Name + '.XFDF';
attachment.ParentId = c.Id;
insert attachment;
PageReference contactPage = new PageReference('/' + c.id);
contactPage.setRedirect(true);
return contactPage;
}
-
- phantom1982
- January 27, 2011
- Like
- 0
- Continue reading or reply
Help on trigger to create the total of transactions
Hi
I have two objects here
1)Transactions
2)Achieved
I have a field on Transactions named Amount
and a field on Achieved name Total Value
If a user does 7 transactions in a financial year , I want the total of the 7 transaction object Amount field to add up to the Total Value field on Achieved object.
If the user deletes the transaction, the Total value field should be deducted also.
Financial year is 1 Jan 2012 - 31 DEC 2012. The transaction should be decided based on the created date.
Please help me on this
Thanks
- phantom1982
- April 18, 2012
- Like
- 0
- Continue reading or reply
Open Activity Count on Accounts
Hi
I have a custom field which is Open Activity Count.
I want to have the count of all the tasks that are open on the account to appear on the field.
For example if I create an account , automatically 3 tasks get created. I want the number 3 to appear automatically on the Open Activity Count field.
If I create another account record type, then 4 tasks may get created automatically.
If I manually create a task from the Open Activities related list, then also the number should appear in the Open Activity Count field.
I want the count of all the tasks in the open activities related list which have been created automatically(i.e by a workflow rule, trigger etc) or manually(i.e. by creating it on the open activities related list ) to appear in the Open Activity Count field.
If I close the task then the count should get deducted.
Can anyone please help me with this.
Thanks in advance
- phantom1982
- March 05, 2012
- Like
- 0
- Continue reading or reply
Hiding Event Details
A quick question, is it possible to hide Event details (like related account/ contact) while the sharing on account is public?
Thanks
- phantom1982
- October 13, 2011
- Like
- 0
- Continue reading or reply
Constructing a URL with Parameters
Hi,
I have to implement a salesforce to SMS function where user will be able to send an sms from salesforce to client. I am facing a bit of challenge in constructing the URL with parameters in it, that is sent to the SMS service. The SMS text is formatted in a sense that it ends with the Sender Name, Mobile and Company Name e.g:
_____________________
This is the test SMS Text
Sender Name
Mobile Phone
Company
____________________
The problem is in the characters used for formatting the text \n and \r. Below is the code:
public PageReference sendSMS(){ User u = [select FirstName, LastName, MobilePhone from User where Username =: UserInfo.getUserName()]; SMS__c sms = [select SMS_Text__c, Account__c from SMS__c where id = :ApexPages.currentPage().getParameters().get('id')]; Account acc = [Select Phone from Account where Id = :sms.Account__c]; String smstext = sms.SMS_Text__c+'\n\n'+u.FirstName+' '+u.LastName+'\n'+u.MobilePhone+'\nCyber Consultants'; //sms.SMS_Text__c = smstext; //insert sms; String myurl = 'http://mytestcompany.com/sendurlcomma.asp?user=200335466&pwd=jn23e52&senderid=ABC&mobileno='+acc.Phone+'&msgtext='+smstext+'&priority=High&CountryCode=+971'; PageReference mypage = new PageReference(myurl); mypage.setRedirect(true); return myPage; }
Pleas if anyone can lead me to the right direction in generating the proper URL.
- phantom1982
- August 09, 2011
- Like
- 0
- Continue reading or reply
Trigger Problem
Hi,
I wrote a trigger that serves to update a custom field on an object. The field actually gets updated with the change in price of the item. Now am kind of stuck with it if I use the before update trigger, it shows the second last change in the price. I cannot use the After update as record gets locked and I cannot update the field value. Below is the trigger code:
trigger TrackPRICEupdate on pb__InventoryItem__c(before update) { pb__InventoryItem__History invh = new pb__InventoryItem__History(); for(pb__InventoryItem__c inv: trigger.new){ invh = [Select NEWVALUE, FIELD, OLDVALUE, CREATEDDATE, PARENTID from pb__InventoryItem__History where PARENTID = :inv.id and FIELD = 'pb__PurchaseListPrice__c' order by CREATEDDATE DESC LIMIT 1]; if(invh.oldvalue <> null && invh.newvalue <> null) { string a = string.valueof(invh.oldvalue); string b = string.valueof(invh.newvalue); decimal old = decimal.valueof(a); decimal newv = decimal.valueof(b); inv.price_change__c = newv - old; } //update inv; } }
Anyone can help?
- phantom1982
- June 20, 2011
- Like
- 0
- Continue reading or reply
Too many SOQL queries exception even when the query is outside for loop
I am not understanding why I am getting this exception when I run tests on the apex test class that is related to a trigger. The exception is being thrown at the following line(where I am querying for total child cases) in trigger when I 'Run tests' on the respective test class. Any help is very much appreciated.
List<Case> parToTotalChildsCases = [Select Id, Status, parentID from Case where ParentId IN :offParList and IsDeleted = false]; // get total child cases for each parent for (case c: parToTotalChildsCases){ system.debug('child ID in total==='+c.Id); parToTotalChilds.put(c.parentId, totalCount++); }
- sanju21
- April 15, 2011
- Like
- 0
- Continue reading or reply
Scope of variable in a Controller class
Can someone please explian the following?
Public Class AController{
Public AController(){}
Private boolean a = false;
Public firstupdatea{
this.a = true;
}
// this is called from the VF page in an action tag.
Public PageReference updatea(){
if (this.a == true){
// further actions..
}
}
}
Can someone please tell if the boolean a will retain the value (set to true) in the firstupdatea() function, when checked in the if condition in updatea()? if not? why and how can to make it work so it retains the value..
Thanks
- phantom1982
- April 12, 2011
- Like
- 0
- Continue reading or reply
Updating a custom object
Can someone please explain the standard way to update a custom object from an APEX class?
Thanks
- phantom1982
- April 10, 2011
- Like
- 0
- Continue reading or reply
Simple question
Hi Code Gurus,
Can someone plesae tell if we can use a List of standard objects with all its available methods like size() etc in a constructor?
this.email_c = parameters.get('PersonEmail'); this.dup = [SELECT id from Account WHERE PersonEmail =: email_c]; if(dup.size()>0){ this.duplicatelead = true; }
this code should set the duplicatelead to true everytime there's a duplicate record on the basis of email. But its not happening, the list size stays 0 always. Any idea why?
- phantom1982
- March 13, 2011
- Like
- 0
- Continue reading or reply
System.NullPointerException
The below code runs fine in testing environment, it's actually generating a PDF document.
public with sharing class PDFTransactionSlip {
public PDFTransactionSlip() {
}
public PDFTransactionSlip(ApexPages.StandardController controller) {
}
private String getXmlString(pb__Agreement__c c)
{
//datetime todayis = system.now();
double skcomdue = c.Buyer_Agency_Fee__c + c.Seller_Agency_Fee__c;
double premiumseller = c.pb__PurchaseListPrice__c - c.Inventory_Original_Price__c;
String s = '<?xml version="1.0" encoding="UTF-8"?>' +
'<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' +
'<f href="https://na*.salesforce.com/resource/1298882850000/Transaction_Slip"/>' +
'<fields>' +
'<field name="Transaction_Type"><value>' + c.pb__AgreementType__c + '</value></field>' +
'<field name="Buyer_Type"><value>' + c.Buyer_Type__c + '</value></field>' +
'<field name="Buyer_Name"><value>' +c.Buyer_Name__c + '</value></field>' +
'<field name="Buyer_No"><value>' + c.Buyer_Phone_No__c + '</value></field>' +
'<field name="Buyer_Address"><value>' + c.Buyer_Address__c + '</value></field>' +
'<field name="Buyer_Pasport"><value>' + c.Buyer_Passport_No__c+ '</value></field>' +
'<field name="Buyer_Nationality"><value>' + c.pb__AccountRegistrationCountry__c + '</value></field>' +
'<field name="Seller_Type"><value>' + c.Seller_Type__c + '</value></field>' +
'<field name="Seller_Name"><value>' + c.pb__SellerFullName__c + '</value></field>' +
'<field name="Seller_No"><value>' + c.seller_Phone_no__c + '</value></field>' +
'<field name="Seller_Address"><value>' + c.Seller_Address__c + '</value></field>' +
'<field name="Seller_Pasport"><value>' + c.Seller_Passport_No__c + '</value></field>' +
'<field name="Seller_Nationality"><value>' + c.Seller_Country__c + '</value></field>' +
'<field name="Developer"><value>' + c.pb__DeveloperRegistrationNumber__c + '</value></field>' +
'<field name="PSA Date"><value>' + c.pb__AgreementDate__c + '</value></field>' +
'<field name="Unit_Details"><value>' + c.pb__UnitName__c + '</value></field>' +
'<field name="No_Of_Bedrooms"><value>' + c.pb__UnitBedrooms__c + '</value></field>' +
'<field name="Sqft"><value>' + c.pb__TotalAreaSqft__c + '</value></field>' +
'<field name="Built_Up"><value>' + c.pb__TotalAreaSqft__c + '</value></field>' +
'<field name="Original_Price"><value>' + c.Inventory_Original_Price__c + '</value></field>' +
'<field name="Net_Purchase_Price"><value>' + c.pb__PurchaseListPrice__c + '</value></field>' +
'<field name="Amount_Paid"><value>' + c.Amount_Paid_on_Property__c + '</value></field>' +
'<field name="Premium_Seller"><value>' + premiumseller + '</value></field>' +
'<field name="Deposit Amount"><value>' + c.Deposit_Amount__c + '</value></field>' +
'<field name="Transfer_Fee"><value>' + c.Transfer_Fee__c + '</value></field>' +
'<field name="Total_Purchase"><value>' + c.Total_Purchase_Price_AED__c + '</value></field>' +
'<field name="Buyer_Agency"><value>' + c.Buyer_Agency_Fee__c + '</value></field>' +
'<field name="Seller_Agency"><value>' + c.Seller_Agency_Fee__c + '</value></field>' +
'<field name="Conveyance_Fees"><value>' + c.Conveyance_Fees__c + '</value></field>' +
'<field name="SK_Commission_Due"><value>' + skcomdue + '</value></field>' +
'<field name="Total_Commission"><value>' + skcomdue+ '</value></field>' +
'</fields><ids original="6CF3C495DE77414F85BC24E6CFC3F692" modified="EF5CB2FB7A5BAA4FB634933ADC944031"/>' +
'</xfdf>';
return s;
}
public PageReference XFDFInit()
{
LIST<pb__Agreement__c> c = [Select Agreed_Price__c,pb__AgreementType__c,
pb__AccountRegistrationCountry__c , Amount_Paid_on_Property__c, Buyer_Agency_Fee__c,
Buyer_Conveyance_Fee__c,Buyer_Phone_No__c, Buyer_Address__c, Buyer_Passport_No__c,
Buyer_Type__c, Cheque_Data__c, Conveyance_Fees__c,
Deposit_Amount__c,Buyer_Name__c, Deposit_Status__c, Id, Initial_Term_SKadded__c,
Inventor_Title_No__c, Inventory_Completion_Status__c, Inventory_Original_Price__c,
Landlord_Commision__c, Mortgage_Discharge_Fee__c, Mortgage_Registration_Fee__c,
Name, Net_Achievable_Price_to_Seller1__c, NOC_Fee_to_Developer__c,
Number_of_Cheques_Required__c, pb__AccountId__c, pb__DeveloperId__c,
pb__DeveloperRegistrationNumber__c, pb__DownPaymentsComplete__c,
pb__FeesComplete__c, pb__InventoryId__c, pb__ItemCompletionStatus__c,
pb__OfferId__c,seller_phone_no__c, pb__PurchaseListPrice__c, pb__PurchasePrice__c,
pb__SellerFullName__c, pb__SellerId__c, pb__Status__c, pb__TotalAmount__c,
pb__TotalAreaSqft__c, pb__TotalAreaSqm__c, pb__UnitBedrooms__c,
pb__UnitFloorNumber__c, pb__UnitName__c, pb__UnitType__c,
Seller_Address__c, Seller_Agency_Fee__c, Seller_Conveyance_Fee__c,
Seller_Country__c, pb__AgreementDate__c , Seller_Passport_No__c, Seller_Type__c,
Service_Maintenance_Fee_Pro_rata__c, Tenant_Commission__c,
Title_Deed__c, Total_Purchase_Price_AED__c, Transfer_Date__c,
Transfer_Fee__c, Unit_Number__c from pb__Agreement__c
WHERE id = :ApexPages.currentPage().getParameters().get('id') limit 1];
if(c.size() > 0){
pb__Agreement__c nc = c[0];
String xmlContent = getXmlString(nc);
Attachment attachment = new Attachment();
attachment.Body = Blob.valueOf(xmlContent);
attachment.Name = 'Transaction_Slip_' + c[0].Name + '_' + System.now() + '.XFDF';
attachment.ParentId = c[0].Id;
insert attachment;
PageReference contactPage = new PageReference('/' + c[0].id);
contactPage.setRedirect(true);
return contactPage;
}
PageReference contactPage = new PageReference('/' + ApexPages.currentPage().getParameters().get('id'));
contactPage.setRedirect(true);
return contactPage;
}
}
Problem is when try to execute it in production, it gives the following exception:
System.NullPointerException: Attempt to de-reference a null object
Class.PDFTransactionSlip.getXmlString: line 12, column 26 Class.PDFTransactionSlip.XFDFInit: line 85, column 29 External entry point
- phantom1982
- March 02, 2011
- Like
- 0
- Continue reading or reply
Record types with different pages
Hi Folks,
I created two record types, custom page for one record type and standard page for another record type. how to write code for setting this pages with different pagelayouts. Functionality is different for two pages.
thanks,
krish
- krish4u
- February 15, 2011
- Like
- 0
- Continue reading or reply
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
Hi,
I am trying to create an Event through apex, everything seems fine in the Sandbox but the deployment fails
System.DMLException:Insert Failed. First exception on row 0; First error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UpdateCalendar, Execution of Before Insert.
with the following warning in IDE.
WARN [2011-02-15 14:34:40,447] (DeploymentController.java:deployWork:993) - Deployment FAILED. Got the following deploy messages [3]:
(1) filename = classes/UnitTestsUpdateCalendar.cls, result = SUCCESS, affect = changed, id = 01pA00000023yriIAA, fullname = UnitTestsUpdateCalendar
(2) filename = package.xml, result = SUCCESS, affect = changed, id = null, fullname = package.xml
(3) filename = triggers/UpdateCalendar.trigger, result = SUCCESS, affect = changed, id = 01qA0000000dSiqIAE, fullname = UpdateCalendar
The trigger is below, its basically creating an event using values from another object..
trigger UpdateCalendar on SFDC_PTO_Request__c (before insert) { if (trigger.isInsert){ for(SFDC_PTO_Request__c pto: trigger.new){ Event evt = new Event(); evt.StartDateTime = pto.Request_Start_Date__c; evt.EndDateTime = pto.Request_End_Date__c; evt.Description = 'The user is having a ' + pto.Request_Type__c; //evt.ShowAs = 'Out of Office'; SFDC_Employee__c emp = [Select Name from SFDC_Employee__c WHERE Id =: pto.Employee__c]; User u = [SELECT Id from User WHERE Name =: emp.Name]; evt.OwnerId = u.Id; evt.Subject = pto.Request_Type__c; insert evt; } } }
The test class is below:
@isTest private class UnitTestsUpdateCalendar { static testMethod void myUnitTest() { SFDC_PTO_Request__c pto = new SFDC_PTO_Request__c(); DateTime dT = System.now(); Date myDate = date.newinstance(dT.year(), dT.month(), dT.day()); pto.Request_Start_Date__c = myDate; pto.Request_End_Date__c = myDate; list<SFDC_Employee__c> emp= [Select Id from SFDC_Employee__c where Name =: 'Admin Support Propertybase']; if (emp.size()>0){ pto.Employee__c = emp[0].Id; } insert pto; } }
- phantom1982
- February 15, 2011
- Like
- 0
- Continue reading or reply
Why is a trigger not "Is Valid"?
I can't seem to find documentation explaining why a trigger does not have the "Is Valid" flag checked on the Setup interface.
Can somebody shed some light on this or reference me to a resource explaining this?
Much appreciated.
- AlexPHP
- March 02, 2010
- Like
- 0
- Continue reading or reply