-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
65Questions
-
76Replies
HTTP RESPONSE ERROR
Getting Below Error when trying to delete file from AMAZON
23:47:09.133 (133643000)|SYSTEM_METHOD_ENTRY|[306]|System.Http.send(APEX_OBJECT)
23:47:09.133 (133797000)|CALLOUT_REQUEST|[306]|System.HttpRequest[Endpoint=https://s3.amazonaws.com/bucketname/filename, Method=DELETE]
23:47:09.250 (250054000)|CALLOUT_RESPONSE|[306]|System.HttpResponse[Status=Bad Request, StatusCode=400]
HERE UNDER BUCKET NAME AND FILENAME Im Providing Respective bucket name and file name which has to be deleted.
public pagereference deletefile(){
String dateString = Datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z');
String stringToSign = 'DELETE\n' +
'\n' +
'\n' +
dateString + '\n' +
('https://s3.amazonaws.com/bucketname goes here/file name goes here').replaceAll(' ', '');
stringToSign = stringToSign.replaceAll(' ', '%20');
System.debug('FINDME::stringToSign - ' + stringToSign);
Blob mac = Crypto.generateMac('hmacSHA1',Blob.valueOf(stringToSign), Blob.valueOf('secret'));
stringToSign = EncodingUtil.base64Encode(mac);
//String encoded = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
HttpRequest con = new HttpRequest();
con.setHeader('Authorization','AKIAIO55ACM6IO2EACFQ:' + stringToSign);
con.setEndPoint('https://s3.amazonaws.com'+'/bucket name goes here/file name here');
con.setHeader('Host','BN.s3.amazonaws.com');
//con.setHeader('Date', dateString);
con.setMethod('DELETE');
Http http = new Http();
HTTPResponse res = http.send(con);
System.debug('RES.GETBODY: ' + res.getBody() + ' RES.GETSTATUS: ' + res.getStatus() + ' CON.GETENDPT: ' + con.getEndPoint());
if (res.getStatusCode() >= 400) {
//delete ifc;
string ABD ='ABD';
system.debug('*&*&*&*&*'+ABD);
}
return null;
}
- street
- July 10, 2012
- Like
- 0
- Continue reading or reply
test case help
how to cover this value in test case
HttpResponse r = makeRequest( baseUrl , | |
'privatekey='+ secret + | |
'&remoteip=' + remoteHost + | |
'&challenge=' + challenge + | |
'&response=' + response + | |
'&error=incorrect-captcha-sol' | |
); |
- street
- July 04, 2012
- Like
- 0
- Continue reading or reply
validation rule not working
Check/ DD date should be kept equal or greater than Receipt date.
Check_DD_Date__c >= Receipt_Date__c
Its not working validation rule.
- street
- May 16, 2012
- Like
- 0
- Continue reading or reply
Bulkification of below code.
trigger UpdateTenantAllocation on Tenant_Allocations__c (after update)
{
public list<Invoice_and_Billing_Detail__c> INVBD {get;set;}
INVBD = new List<Invoice_and_Billing_Detail__c>();
for(Tenant_Allocations__c t:trigger.new)
{
Location__c l1=[select id,Bill_Tenants__c from location__c where id=:t.Location_new__c];
system.debug('............'+l1);
Invoice_and_Billing_Detail__c[] lb=[select id,Rate__c, name,Location1__c from Invoice_and_Billing_Detail__c where Location1__c=:l1.id and QB_Txn_ID__c=null ];
system.debug('............'+lb);
for(Invoice_and_Billing_Detail__c lb1:lb){
if(l1.Bill_Tenants__c==true)
{
lb1.Rate__c=t.Next_Period_Invoice_Amount__c;
}
else
{
lb1.Rate__c=222;
}
INVBD.add(lb1);
}
update INVBD;
system.debug('............'+lb);
}
}
- street
- May 15, 2012
- Like
- 0
- Continue reading or reply
Bulkification of below code
trigger UpdateInvoiceBillingDetails on Can__c (before update,after update)
{
//BEFORE UPDATE FOR CAPTURING THE PREVIOUS INFORMATION TO RELATED CUSTOM FIELDS.
if(trigger.isbefore)
{
for(can__c c1:trigger.old)
{
for(Can__c c:trigger.new)
{
try{
Invoice_and_Billing_Detail__c lb=[select id,Service_Description__c,Start_Date__c,Stop_Date__c
from Invoice_and_Billing_Detail__c where id=:c.Last_Invoice_Detail__c];
system.debug('detailll'+lb);
Invoice_and_Billing_Header__c lh=[select id,QB_Invoice_Txn_ID__c from Invoice_and_Billing_Header__c where id=:c.Last_Invoice_Number__c];
//system.debug('header'+lh);
//EXECUTE ON EFFECTIVE DATE OF OLD RECORD AND THE NEW RECORD ARE NOT SAME AND
//THE FIELD QB INVOICE TXN ID SHOULD BE EMPTY IN INVOICE BILLING HEADER.
if(c.Effective_Date__c!=c1.Effective_Date__c && lh.QB_Invoice_Txn_ID__c==null)
{
c.Previous_Start_Date__c=c1.Start_Date__c;
c.Previous_Stop_Date__c=c1.stop_Date__c;
c.Previous_Next_Bill_Amount__c=c1.Next_Bill_Amount_2__c;
c.Previous_Effective_Date__c=c1.Effective_Date__c;
c.Previous_NEXT_INVOICE_AMOUNT_2__c=c1.NEXT_INVOICE_AMOUNT_2__c;
}
}catch(exception e){}}
}
}
if(trigger.isafter)
{
//RETRIEVING THE OLD RECORD TO UPDATE THE FIELDS.
for(can__c c1:trigger.old)
{
for(Can__c c:trigger.new)
{
try{
Invoice_and_Billing_Detail__c lb=[select id,Header_Type__c,Rate__c,Service_Description__c,Start_Date__c,Stop_Date__c
from Invoice_and_Billing_Detail__c where id=:c.Last_Invoice_Detail__c];
system.debug('detailll'+lb);
Invoice_and_Billing_Header__c lh=[select id,QB_Invoice_Txn_ID__c from Invoice_and_Billing_Header__c where id=:c.Last_Invoice_Number__c];
//system.debug('header'+lh);
//EXECUTE ON EFFECTIVE DATE OF OLD RECORD AND THE NEW RECORD ARE NOT SAME AND
//THE FIELD QB INVOICE TXN ID SHOULD BE EMPTY IN INVOICE BILLING HEADER.
if(c.Effective_Date__c!=c1.Effective_Date__c && lh.QB_Invoice_Txn_ID__c==null)
{
lb.Service_Description__c =c.Service_Description__c;
lb.Start_Date__c=c.Start_Date__c;
lb.Stop_Date__c=c.Stop_Date__c;
//if(‘Client Invoice’) then RATE= NEXT_INVOICE_AMOUNT_2__C else NEXT_BILL_AMOUNT_2__C
if(lb.Header_Type__c=='Client Invoice')
{
lb.Rate__c=c.NEXT_INVOICE_AMOUNT_2__C;
}
else{
lb.Rate__c=c.NEXT_BILL_AMOUNT_2__C;
}
update lb;
}
}catch(exception e){}
}
}
}
}
- street
- May 15, 2012
- Like
- 0
- Continue reading or reply
Customer Portal browser back button issue!!
Can we disable customer protal browser back button , as im using frames and standard tabs ...its giving this below error when clicking back button:
Confirm Form Resubmission
- street
- April 23, 2012
- Like
- 0
- Continue reading or reply
Testcase issue coverage
public class Netsmart_Portal_Homepage{ public list<case> opencaserecords{get;set;} public list<case> closedcaserecords{get;set;} public list<case> caserecords{get;set;} public user u{get;set;} public contact c{get;set;} public Netsmart_Portal_Homepage(){ u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()]; c = [Select LastName,id from Contact where id =:u.Contactid]; caserecords=[select id,CaseNumber,Subject,Status, Priority ,CreatedBy.FirstName,CreatedDate,CreatedBy.id,ClosedDate from case where ContactId=:c.id ]; closedcaserecords=[select id,CaseNumber,Subject,Status, Priority ,CreatedDate,CreatedBy.FirstName,CreatedBy.id,ClosedDate from case where ContactId=:c.id and isclosed=true]; opencaserecords=[select id,Subject,CaseNumber,Status, Priority ,CreatedDate,CreatedBy.FirstName,CreatedBy.id,ClosedDate from case where ContactId=:c.id and isclosed=false]; } }
Unable to cover this line: c = [Select LastName,id from Contact where id =:u.Contactid];
list has no rows im getting error
this is my testcase:
@istest
private class Netsmart_Portal_Homepage_Tc
{
static testMethod void validatetest1()
{
Account a = new account();
a.name = 'Test';
a.Type = 'New Customer';
a.BillingState = 'AL';
a.recordtypeid='0127000000014u3';
insert a;
user u=[select id,contactid from user where isactive=true limit 1];
System.RunAs(u){
contact c1=[select id from contact where id=:u.contactid];
case c11=new case();
c11.Subject='aaa';
c11.Status='open';
c11.ContactId=c1.id;
c11.AccountId =a.id;
insert c11;
Netsmart_Portal_Homepage n1 =new Netsmart_Portal_Homepage();
}
}
}
- street
- April 19, 2012
- Like
- 0
- Continue reading or reply
Page level condition checking
I have a field on Visualforce page( Buying)which contains Amount for eg: 300rps values in rupees.
Now there is a field(Enter amount) on same page(buying)
where the amount to be to entered in it and submit..
Now there should be condition checking on pagelevel that Enter amount field should be less than Amount.
I need this to check on page Enter amount <= amount
HOw can i check on page itself. tried action support using onchange on field Enter amount.
Any help will be thankfull.
- street
- April 11, 2012
- Like
- 0
- Continue reading or reply
document.getElementById
How to call inputfield value which is in page block from javascript.
function test()
{
var end_date=document.getElementById(ttt);
}
<apex:column headerValue="Value1" id="e">
<apex:inputfield id="ttt" value="{!Is_rate}" >
</apex:inputfield>
- street
- April 11, 2012
- Like
- 0
- Continue reading or reply
Record level security in customer portal
I have a object "TestImp" which is displayed in customer portal as a tab,
once the customer portal clicks on the "Testimp" tab should only display his particular records. How to work on this setting??
- street
- April 11, 2012
- Like
- 0
- Continue reading or reply
homecomponent problem
how to remove the toolbar from homecomponent. i have uploaded homecomponent to production then under the page the code toolbar is also appearing..........how to remove that any suggestions!!!!
- street
- April 06, 2012
- Like
- 0
- Continue reading or reply
validation rule
I have a picklist with values
1) open
2) None
only the admin or developer Profile can select picklist value "None" then the picklist has to update the picklist, all other profiles if selects "None" sholud rise the validation error.
- street
- April 04, 2012
- Like
- 0
- Continue reading or reply
Problem with rich text on visual force page.
I have a field(Text area) in a object, when im entering the text about 400 lines as paragraphs, after displaying the same on visual force page its displaying as breaks tags on page.
so any solution for it to remove breaks tags on visual force page.
- street
- March 31, 2012
- Like
- 0
- Continue reading or reply
Testcase error
trigger Assert_Creation on OpportunityLineItem (after insert) { for(OpportunityLineItem oli:trigger.new) { opportunity o=[select id,Accountid,Name,Manager__r.name,Sales_Consultan__r.name,Sales_Consultan__c, Process_Consultant_User__r.name,Process_Consultant_Manager__r.name, Branch__c,Payment_Option__c,Sales_Date__c,Process_Stage__c from opportunity where id=:oli.opportunityid]; asset a=new asset(); a.name=o.name; a.Accountid=o.Accountid; a.Sales_Consultant1__c=o.Sales_Consultan__c; a.Sales_Consultant_Manager1__c=o.Manager__c; a.Process_Consultant1__c=o.Process_Consultant_User__c; a.Process_Consultant_Manager1__c=o.Process_Consultant_Manager__c; a.Branch__c=o.Branch__c; a.Payment_Option__c=o.Payment_Option__c; a.Expected_Sale_Date__c=o.Sales_Date__c; a.Process_Stage__c=o.Process_Stage__c; a.opportunity__c=o.id; insert a; } } |
I have written Like this
@isTest
private class Assert_Creation_TC {
static testMethod void validateabc() {
Branch__c b= new Branch__c();
b.Name='sdf';
b.Branch_Code__c='xc';
b.City__c='df';
b.City__c='ww';
b.Pin_Code__c='wewe';
b.Invoice_Number_Cash__c=23;
b.Invoice_Number_General__c=23;
b.Invoice_Number_Online__c=23;
insert b;
account a= new account();
a.name='dsad';
insert a;
user u = [select id from user limit 1];
//Pricebook2 standardPB = [select id from Pricebook2 limit 1];
Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
insert pb;
Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', IsActive = true);
PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id,Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
insert pbe;
opportunity o = new opportunity();
o.Name='ssd';
o.CloseDate=date.ValueOf('2011-09-21');
o.Branch__c=b.id;
o.Manager__c=u.id;
o.Payment_Option__c='Full Payment';
o.StageName='Follow up for Evaluation';
o.Accountid=a.id;
insert o;
update o;
opportunitylineitem op=new opportunitylineitem();
op.Quantity=1;
op.UnitPrice=76;
op.OpportunityId=o.id;
op.PricebookEntryId = pbe.id;
insert op;
asset ass=new asset();
ass.name=o.name;
}
}
Here is the error:
Method NameTotal Time (ms)MessageStack Trace
Assert_Creation_TC.validateabc | 461.0 | System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Product2Id]: [Product2Id] | Class.Assert_Creation_TC.validateabc: line 32, column 1 |
- street
- March 30, 2012
- Like
- 0
- Continue reading or reply
Bulkification of the trigger
trigger Update_Actualtime_Projecttask on Timesheet__c(after insert, after update)
{
for(Timesheet__c t:trigger.new)
{
Project_Task__c p =[select id,Project__c , Actual_Time__c from Project_Task__c where id=:t.Project_Task__c and project__c=:t.project__c];
Timesheet__c[] t1=[select id,Effort_in_hours__c from Timesheet__c where project__c =:p.project__c and Project_Task__c =:p.id];
Decimal id2num =0.0;
p.Actual_Time__c=0;
for(Timesheet__c t2:t1)
{
id2num =t2.Effort_in_hours__c + id2num;
p.Actual_Time__c = id2num;
update p;
}
}
}
bulkification of the trigger
- street
- March 30, 2012
- Like
- 0
- Continue reading or reply
New validation rule
If the Mode1(Picklist field) ivalue is "HELLO" the below mentioned fields should be made mandatory .
C1 (Textfield)
Date (date field)
- street
- March 27, 2012
- Like
- 0
- Continue reading or reply
Date format issue in apex class
I need date to be Formated to DD-MM-YYYY(02-03-2012)
But its coming as D-MM--YYYY(2-03-2012)
I need like this(02-03-2012)
Here is my code:
string DateString ;
string mon;
if(d1!=null)
{
integer red1 = d1.day();
integer red2 = d1.month();
if(red2==1){
mon = '01';
}
else if(red2==2){
mon = '02';
}
else if(red2==3){
mon = '03';
}
else if(red2==4){
mon = '04';
}
else if(red2==5){
mon = '05';
}
else if(red2==6){
mon = '06';
}
else if(red2==7){
mon = '07';
}
else if(red2==8){
mon = '08';
}
else if(red2==9){
mon = '09';
}
else if(red2==10){
mon = '10';
}
else if(red2==11){
mon = '11';
}
else if(red2==12){
mon = '12';
}
integer red3 = d1.year();
DateString = string.valueOf(red1)+'-'+mon+'-'+string.valueOf(red3);
}
- street
- March 02, 2012
- Like
- 0
- Continue reading or reply
Trigger, Where to to check the multi select Picklist contains.
I have trigger where i need to check a Multi select picklist value if it contains Value Temporary then the value has to update by entering into If() Condition as shown below.
trigger Update_Candidate_TempLocation on Contact (before insert,before update)
{
for(Contact c:trigger.new)
{
if(c.Candidate_Position_Type_IDs_New__c=='temporary' && c.RecordTypeid=='012D0000000hW06')
{
c.Candidate_Temp_Location_New__c=c.MailingState ;
}
}
}
This is my code. How to look into it, if multi select picklist contains Temporary!!!
- street
- March 02, 2012
- Like
- 0
- Continue reading or reply
Help in trigger
i have object "Place" which contain "Next Travel date" Field.
I have Other Object Contact (Standard object) contains a field "Travel date"
Both are in relationship as lookup. there is a lookup field on Place for Contact.
Now when every time place gets update. all the records in it atonce.
the field of contact has to be updated with place travel date which are related to eachother.
trigger Candidate_Update on AVTRRT__Placement__c (after update)
{
for(AVTRRT__Placement__c winv:trigger.new)
{
contact ct=[select AVTRRT__Candidate_Id__c,Candidate_Travel_Date__c from contact where RecordTypeId='012D0000000hW06' and id=:winv.AVTRRT__Contact_Candidate__c];
if(ct.Candidate_Travel_Date__c!=winv.AVTRRT_Next_Travel__c)
{
ct.Candidate_Travel_Date__c=winv.AVTRRT_Next_Travel__c;
update ct;
}
}
}
Want it to make bulkify. I have no idea on bulkyfication.
- street
- February 29, 2012
- Like
- 0
- Continue reading or reply
Error in Testcase for below Trigger.
This is trigger:
trigger placement_enddate on AVTRRT__Placement__c (before insert) {
for(AVTRRT__Placement__c plc:trigger.new)
{
AVTRRT__Job_Applicant__c japp=[select AVTRRT__Job__r.AVTRRT__Estimated_Close_Date__c from AVTRRT__Job_Applicant__c where id=:plc.AVTRRT__Job_Applicant__c ];
plc.AVTRRT__End_Date__c =japp.AVTRRT__Job__r.AVTRRT__Estimated_Close_Date__c;
}
}
Here Is the Testcase below:
@isTest
private class placement_enddate_TC
{
static testMethod void myUnitTest()
{
Profile p = [select id from profile where name='Standard User'];
User u = new User(alias = 'standt', email='standarduser@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');
account acct=new account();
acct.Name='Test account';
insert acct;
AVTRRT__Job__c jb=new AVTRRT__Job__c();
jb.AVTRRT__Job_Title__c='Test Functional';
jb.AVTRRT__Start_Date__c=date.ValueOf('2012-03-16');
insert jb; // Showing error here while running the testcase!!!
contact ct=new contact();
ct.RecordType.id = '012D0000000hW06';
ct.LastName='test candidate';
insert ct;
AVTRRT__Job_Applicant__c ja=new AVTRRT__Job_Applicant__c();
ja.AVTRRT__Job__c=jb.id;
ja.AVTRRT__Contact_Candidate__c=ct.id;
insert ja;
AVTRRT__Placement__c a=new AVTRRT__Placement__c();
a.AVTRRT__Start_Date__c=date.ValueOf('2012-03-16');
insert a;
}}
Method NameTotal Time (ms)MessageStack Trace
placement_enddate_TC.myUnitTest | 234.0 | System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AVTRRT.Trigger_Job: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object (AVTRRT): [] | Class.placement_enddate_TC.myUnitTest: line 28, column 1 |
- street
- February 24, 2012
- Like
- 0
- Continue reading or reply
Create a custom Web service in Salesforce and consume it in other salesforce instance
Example or procedure to Create a custom Web service in Salesforce and consume it in other salesforce instance???
- street
- December 29, 2011
- Like
- 1
- Continue reading or reply
validation rule not working
Check/ DD date should be kept equal or greater than Receipt date.
Check_DD_Date__c >= Receipt_Date__c
Its not working validation rule.
- street
- May 16, 2012
- Like
- 0
- Continue reading or reply
bulkification of trigger
HI
I had wrote a trigger .it is working fine but now i want to bulkify my trigger...please help me to bulkification.
I am sending thte trigger .
please help me for bulkification.....thanks in advance
Trigger:
- ran67
- May 16, 2012
- Like
- 0
- Continue reading or reply
Page level condition checking
I have a field on Visualforce page( Buying)which contains Amount for eg: 300rps values in rupees.
Now there is a field(Enter amount) on same page(buying)
where the amount to be to entered in it and submit..
Now there should be condition checking on pagelevel that Enter amount field should be less than Amount.
I need this to check on page Enter amount <= amount
HOw can i check on page itself. tried action support using onchange on field Enter amount.
Any help will be thankfull.
- street
- April 11, 2012
- Like
- 0
- Continue reading or reply
document.getElementById
How to call inputfield value which is in page block from javascript.
function test()
{
var end_date=document.getElementById(ttt);
}
<apex:column headerValue="Value1" id="e">
<apex:inputfield id="ttt" value="{!Is_rate}" >
</apex:inputfield>
- street
- April 11, 2012
- Like
- 0
- Continue reading or reply
homecomponent problem
how to remove the toolbar from homecomponent. i have uploaded homecomponent to production then under the page the code toolbar is also appearing..........how to remove that any suggestions!!!!
- street
- April 06, 2012
- Like
- 0
- Continue reading or reply
validation rule
I have a picklist with values
1) open
2) None
only the admin or developer Profile can select picklist value "None" then the picklist has to update the picklist, all other profiles if selects "None" sholud rise the validation error.
- street
- April 04, 2012
- Like
- 0
- Continue reading or reply
Testcase error
trigger Assert_Creation on OpportunityLineItem (after insert) { for(OpportunityLineItem oli:trigger.new) { opportunity o=[select id,Accountid,Name,Manager__r.name,Sales_Consultan__r.name,Sales_Consultan__c, Process_Consultant_User__r.name,Process_Consultant_Manager__r.name, Branch__c,Payment_Option__c,Sales_Date__c,Process_Stage__c from opportunity where id=:oli.opportunityid]; asset a=new asset(); a.name=o.name; a.Accountid=o.Accountid; a.Sales_Consultant1__c=o.Sales_Consultan__c; a.Sales_Consultant_Manager1__c=o.Manager__c; a.Process_Consultant1__c=o.Process_Consultant_User__c; a.Process_Consultant_Manager1__c=o.Process_Consultant_Manager__c; a.Branch__c=o.Branch__c; a.Payment_Option__c=o.Payment_Option__c; a.Expected_Sale_Date__c=o.Sales_Date__c; a.Process_Stage__c=o.Process_Stage__c; a.opportunity__c=o.id; insert a; } } |
I have written Like this
@isTest
private class Assert_Creation_TC {
static testMethod void validateabc() {
Branch__c b= new Branch__c();
b.Name='sdf';
b.Branch_Code__c='xc';
b.City__c='df';
b.City__c='ww';
b.Pin_Code__c='wewe';
b.Invoice_Number_Cash__c=23;
b.Invoice_Number_General__c=23;
b.Invoice_Number_Online__c=23;
insert b;
account a= new account();
a.name='dsad';
insert a;
user u = [select id from user limit 1];
//Pricebook2 standardPB = [select id from Pricebook2 limit 1];
Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true);
insert pb;
Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'Best Practices', IsActive = true);
PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id,Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
insert pbe;
opportunity o = new opportunity();
o.Name='ssd';
o.CloseDate=date.ValueOf('2011-09-21');
o.Branch__c=b.id;
o.Manager__c=u.id;
o.Payment_Option__c='Full Payment';
o.StageName='Follow up for Evaluation';
o.Accountid=a.id;
insert o;
update o;
opportunitylineitem op=new opportunitylineitem();
op.Quantity=1;
op.UnitPrice=76;
op.OpportunityId=o.id;
op.PricebookEntryId = pbe.id;
insert op;
asset ass=new asset();
ass.name=o.name;
}
}
Here is the error:
Method NameTotal Time (ms)MessageStack Trace
Assert_Creation_TC.validateabc | 461.0 | System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Product2Id]: [Product2Id] | Class.Assert_Creation_TC.validateabc: line 32, column 1 |
- street
- March 30, 2012
- Like
- 0
- Continue reading or reply
Bulkification of the trigger
trigger Update_Actualtime_Projecttask on Timesheet__c(after insert, after update)
{
for(Timesheet__c t:trigger.new)
{
Project_Task__c p =[select id,Project__c , Actual_Time__c from Project_Task__c where id=:t.Project_Task__c and project__c=:t.project__c];
Timesheet__c[] t1=[select id,Effort_in_hours__c from Timesheet__c where project__c =:p.project__c and Project_Task__c =:p.id];
Decimal id2num =0.0;
p.Actual_Time__c=0;
for(Timesheet__c t2:t1)
{
id2num =t2.Effort_in_hours__c + id2num;
p.Actual_Time__c = id2num;
update p;
}
}
}
bulkification of the trigger
- street
- March 30, 2012
- Like
- 0
- Continue reading or reply
Trigger, Where to to check the multi select Picklist contains.
I have trigger where i need to check a Multi select picklist value if it contains Value Temporary then the value has to update by entering into If() Condition as shown below.
trigger Update_Candidate_TempLocation on Contact (before insert,before update)
{
for(Contact c:trigger.new)
{
if(c.Candidate_Position_Type_IDs_New__c=='temporary' && c.RecordTypeid=='012D0000000hW06')
{
c.Candidate_Temp_Location_New__c=c.MailingState ;
}
}
}
This is my code. How to look into it, if multi select picklist contains Temporary!!!
- street
- March 02, 2012
- Like
- 0
- Continue reading or reply
Error in Testcase for below Trigger.
This is trigger:
trigger placement_enddate on AVTRRT__Placement__c (before insert) {
for(AVTRRT__Placement__c plc:trigger.new)
{
AVTRRT__Job_Applicant__c japp=[select AVTRRT__Job__r.AVTRRT__Estimated_Close_Date__c from AVTRRT__Job_Applicant__c where id=:plc.AVTRRT__Job_Applicant__c ];
plc.AVTRRT__End_Date__c =japp.AVTRRT__Job__r.AVTRRT__Estimated_Close_Date__c;
}
}
Here Is the Testcase below:
@isTest
private class placement_enddate_TC
{
static testMethod void myUnitTest()
{
Profile p = [select id from profile where name='Standard User'];
User u = new User(alias = 'standt', email='standarduser@testorg.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');
account acct=new account();
acct.Name='Test account';
insert acct;
AVTRRT__Job__c jb=new AVTRRT__Job__c();
jb.AVTRRT__Job_Title__c='Test Functional';
jb.AVTRRT__Start_Date__c=date.ValueOf('2012-03-16');
insert jb; // Showing error here while running the testcase!!!
contact ct=new contact();
ct.RecordType.id = '012D0000000hW06';
ct.LastName='test candidate';
insert ct;
AVTRRT__Job_Applicant__c ja=new AVTRRT__Job_Applicant__c();
ja.AVTRRT__Job__c=jb.id;
ja.AVTRRT__Contact_Candidate__c=ct.id;
insert ja;
AVTRRT__Placement__c a=new AVTRRT__Placement__c();
a.AVTRRT__Start_Date__c=date.ValueOf('2012-03-16');
insert a;
}}
Method NameTotal Time (ms)MessageStack Trace
placement_enddate_TC.myUnitTest | 234.0 | System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AVTRRT.Trigger_Job: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object (AVTRRT): [] | Class.placement_enddate_TC.myUnitTest: line 28, column 1 |
- street
- February 24, 2012
- Like
- 0
- Continue reading or reply
testcase for below class
global class bitly {
Public String mode;
Public String sUrl;
public String getbitly () {
String shorten;
XmlStreamReader reader;
HttpResponse res;
//First, build the http request
Http h = new Http();
HttpRequest req = buildWebServiceRequest(sURL);
//Second, invoke web service call
if (mode=='live') { res = invokeWebService(h, req); }
if (mode=='live') { reader = res.getXmlStreamReader(); }
else
{
String str = '<bitly><results shortUrl="http://bit.ly/QqHEm">Foo bar</results></bitly>';
reader = new XmlStreamReader(str);
}
return readXMLResponse(reader,'shortUrl');
}
public static HttpRequest buildWebServiceRequest(String purl){
String endpoint;
HttpRequest req = new HttpRequest();
endpoint = 'http://api.bitly.com/shorten?version=2.0.1&format=xml&history=1&longUrl=' + purl + '&login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e';
req.setEndpoint(endpoint);
req.setMethod('GET');
return req;
}
public static HttpResponse invokeWebService(Http h, HttpRequest req){
//Invoke Web Service
HttpResponse res = h.send(req);
return res;
}
public static String readXMLResponse(XmlStreamReader reader, String sxmltag){
string retValue;
// Read through the XML
system.debug(reader.toString());
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if (reader.getLocalName() == sxmltag) {
reader.next();
if (reader.getEventType() == XmlTag.characters) {
retValue = reader.getText();
}
}
}
reader.next();
}
return retValue;
}
}
- street
- February 17, 2012
- Like
- 0
- Continue reading or reply
Url Shortening using bitly integration in salesforce
I want use below code..
global class bitly {
Public String mode;
Public String sUrl;
public String getbitly () {
String shorten;
XmlStreamReader reader;
HttpResponse res;
//First, build the http request
Http h = new Http();
HttpRequest req = buildWebServiceRequest(sURL);
//Second, invoke web service call
if (mode=='live') { res = invokeWebService(h, req); }
if (mode=='live') { reader = res.getXmlStreamReader(); }
else
{
String str = '<bitly><results shortUrl="http://bit.ly/QqHEm">Foo bar</results></bitly>';
reader = new XmlStreamReader(str);
}
return readXMLResponse(reader,'shortUrl');
}
public static HttpRequest buildWebServiceRequest(String purl){
String endpoint;
HttpRequest req = new HttpRequest();
endpoint = 'http://api.bit.ly/shorten?version=2.0.1&format=xml&history=1&longUrl=' + purl + '&login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e';
req.setEndpoint(endpoint);
req.setMethod('GET');
return req;
}
public static HttpResponse invokeWebService(Http h, HttpRequest req){
//Invoke Web Service
HttpResponse res = h.send(req);
return res;
}
public static String readXMLResponse(XmlStreamReader reader, String sxmltag){
string retValue;
// Read through the XML
system.debug(reader.toString());
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if (reader.getLocalName() == sxmltag) {
reader.next();
if (reader.getEventType() == XmlTag.characters) {
retValue = reader.getText();
}
}
}
reader.next();
}
return retValue;
}
}
bitly b = new bitly();
b.mode = 'live';
b.sUrl = 'http://www.bridgefarmconsulting.com';
system.debug('Check BitLy' + b.getbitly() );
Im using above code it giving error at endpoint. what to be changed their.
- street
- February 17, 2012
- Like
- 0
- Continue reading or reply
how to call Multiselect picklist value to formula field
How can i create a formula field where it sholud get value from a multiselectpicklist.
Any help!!
- street
- February 08, 2012
- Like
- 0
- Continue reading or reply
Bitly (Url Shortening) Integration with Salesforce
I want to embed javascript coding in visualforce. The javascript coding is for integrating 'Bitly' platform with salesforce.
My visualforce code is:
<apex:form > <apex:inputText value="{!Candidate__c.Long_Url__c}" id="theText" onclick="javascript:go('{!$Component.theText}')" ></apex:inputText> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/11.1/connection.js"></script> <script language="javascript"> function go(f) { var theText = document.getElementById(f).value; alert(theText); } var xhr = new XMLHttpRequest(); xhr.open("GET", "http://api.bitly.com//v3/shorten?login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e&longUrl="+theText); xhr.onreadystatechange = function(){ alert('test'); if(xhr.readyState == 4) { if(xhr.status==200) { var jsonResponse = JSON.parse(xhr.responseText); var bitlyUrl = jsonResponse.data.url; myFunc(bitlyUrl); var t = xhr.send(); } } } </script> </apex:form> <apex:form > <apex:actionFunction name="myFunc" action="{!field}"> <apex:param name="param1" value=""/> </apex:actionFunction> </apex:form> </apex:page>
Bitly is used for URL shortening. I want the shortened url to be passed to the controller through <apex:actionfunction>.
Please help. Its really urgent. I am completely stuck.
Thanks
- Force.com
- May 26, 2011
- Like
- 0
- Continue reading or reply
passing a list from apex controller to javascript..
Hi everyone i have a list in my Apex class which has soql query result..
String query = 'SELECT City,Latitude__c FROM Lead WHERE City LIKE \''+city+'%\'';
leadrecords = Database.query(query);
Eg :in the above line leadrecords is alist of lead type
private List<Lead> leadrecords;
So now iam trying to pass this list to ajavascript variable so dat javascript variable should have query output...but when i have done like this iam able to pass the list but when iam tryong to display that it is displaying the ids but i want to display the field city and latitude which are storesd in that list how to do it please someone help me with the solution... to javascript variable so how to pass this list to javascript variable
- anu_karthi
- March 31, 2010
- Like
- 0
- Continue reading or reply
Insert failed. No standard price difined for this product - help!
hi,
I'm trying to create a test class for a trigger:
trigger deleteTask on OpportunityLineItem (before delete) {
List<OpportunityLineItem> OppLIs = Trigger.old;
List<Task> tasks = new List<Task>();
for (OpportunityLineItem OppLI : OppLIs) {
Opportunity Opp = [ Select OwnerId from Opportunity where id=:OppLI.OpportunityId limit 1 ];
User usuario = [ Select Sociedad__c from User where id=:Opp.OwnerId ];
//el usuario debe pertenecer a argentina = usuario.Sociedad__c == 1000
if ( usuario.Sociedad__c == '1000' ) {
tasks = [ Select Id from Task where whatID=:OppLI.OpportunityId and Subject='Recordatorio: Vencimiento de producto'];
}
}
delete tasks;
}
My test class is:
@isTest
private class deleteTaskTest {
static testMethod void myUnitTest() {
//Create a custom pricebook
Pricebook2 pb = new Pricebook2(Name='Custom Pricebok',IsActive=true);
insert pb;
// Create a new product
Product2 prod = new Product2(IsActive=true, Name='Product');
insert prod;
// Create a pricebook entry for custom pricebook
PricebookEntry pbe2 = new PricebookEntry(Pricebook2Id=pb.Id, Product2Id=prod.Id,
IsActive=true, CurrencyIsoCode='ARS', UnitPrice=100,
UseStandardPrice=false);
insert pbe2;
test.startTest();
delete prod;
test.stopTest();
}
}
When I run this test class, I get this error message:
Insert failed. First exception on row 0; first error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []
In the line: insert pbe2;
Can someone understand why this is happening? Thanks!
- majo
- December 07, 2009
- Like
- 0
- Continue reading or reply
Example Sample HelloWorld WebService needed
I need examples for the foll:
1) How to create Sample HelloWorld WebService using Apex?.
2) How to generate WSDL for this Sample HelloWorld WebService ?.
3) How to consume that Sample HelloWorldWebService in VisualForce page?..
Any Help would be appreciated.
- KrishnakumarJ
- September 11, 2009
- Like
- 0
- Continue reading or reply