• Praveen_K.ax1208
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 11
    Replies

Hi All,

 

I have a requirement to REWRITE the Salesforce urls to user friendly urls..

Can anyone post the working example on this..

 

This will be more helpfull for doing my task..

 

 

Thanks in Advance..

Praveen K. 

trigger Miles on Quote (before insert,before update) {
for(Quote q:trigger.new){
opportunity opp=[select id,Distance_in_Miles__c from opportunity where id=:q.opportunityid limit 1];
q.Delivery_Miles__c=opp.Distance_in_Miles__c;
q.Amount_of_Truck__c=q.Square_Feet_quote__c/10000;
}
}

 

for the above trigger i wrote a test class like this....but this test class is not covering a trigger...

its showing an error like    "Methods defined as TestMethod do not support Web service callouts, test skipped ".....

please solve this problem....

 

@isTest
public class testquote
{
        public static testMethod void QuotetTest()
        {
        account a=new account(name='icc',type='new client',industry='church',phone='9985354198');
        insert a;
        opportunity opp=new opportunity(name='test',Lost_to__c='big top',Distance_in_Miles__c=200.20,StageName='Closed Won',closedate=system.today()+2,leadsource='website',type='rental-new client',address1__c='blr',address2__c='hyd',Application__c='aviation',Budgeted_Cost__c=2500.20,City1__c='las vegas',Divsion__c='builtsure',Country1__c='usa');
                                          
        insert opp;
        
        quote q=new quote(name='test',Due_With_Signed_Agreement__c=30.20,Opportunityid =opp.id,Length_in_Meters__c=20,Title_of_Quote__c='this is shipping',TFS_Type_by_Width__c='20',Due_Prior_to_Shipping__c=20.20,delivery_miles__c=150.20,Amount_of_Truck__c=2000,Amount_Per_Mile__c=20.50,Due_After_Install__c=20,Start_Date__c=system.now().date());
                           
        insert q;
        system.debug(q.delivery_miles__c+'@@@@');
        update opp;
     
       
        update q;

        }

}

 

 

// please solve this......

how to insert bulk records usiing dml operations.?means i wish to add (or)insert 100 records at atime.how to do this pls clarify.it's very urgent.pls

Hi

  I have an apex class which is all about an Opportunity and Quote and Product informations.

 I mean ...Contact--->Opportunity---->Quote-->QuoteLineitem-- Product

 I have written a test method ... I have entered an record of Opportunity and it is already inserted . I have checked bu debur log... But still I am facing an exception...

  System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, StageName, CloseDate]: [Name, StageName, CloseDate]

 

This is my class......

 

   

public class Pcontactdetailcontroller {

//All Getter and Setter Properties.....

public Contact contact {get;set;}
public List< OpportunityContactRole> optcList{get;set;}

public String visible {get;set;}
public String Enable{get;set;}
public OpportunityContactRole optc {get;set;}
public Opportunity opt{get;set;}
public Quote quote{get;set;}
public String opptId{get;set;}
public String table{get;set;}
public String asish{get;set;}
public String block{get;set;}
public Id optId{get;set;}
public Id Id{get;set;}
public Id quoteId{get;set;}
public Id lineitemId{get;set;}
public List<Quote> quotelist{get;set;}
public List<Opportunity> optlist{get;set;}
public PricebookEntry pbentry{get;set;}
public Pricebook2 pb{get;set;}
public Product2 product{get;set;}
public QuoteLineItem qutlineitem{get;set;}
public QuoteLineItem qutlineitem1{get;set;}
public Quote quote1{get;set;}
public Opportunity opt1{get;set;}


//constructor

public Pcontactdetailcontroller() {

Id = ApexPages.currentPage().getParameters().get('Id');
contact=[select Id,FirstName,LastName, name,Account.Name,MailingStreet,MailingState,MailingCity,MobilePhone,Email from Contact where Id=:Id];

optc=new OpportunityContactRole();
opt=new Opportunity();
opt1=new Opportunity();
quote=new Quote();
pb= new Pricebook2();
pbentry= new PricebookEntry(UseStandardPrice=true,UnitPrice=0.00);
product=new Product2();
qutlineitem=new QuoteLineItem();
qutlineitem1=new QuoteLineItem();
quote1 = new Quote();
}



//All getter method

public OpportunityContactRole getOpportunityContactRole() {

return optc;
}

public Opportunity getOpportunity() {

return opt;
}


public Opportunity getOpportunity1() {

return opt1;
}

public Quote getQuote() {

return quote;
}

public Contact getContact() {

return contact;
}

public Product2 getProduct2() {

return product;
}
public Pricebook2 getPricebook2() {

return pb;
}
public PricebookEntry getPricebookEntry() {

return pbentry;
}
public QuoteLineItem getQuoteLineItem() {

return qutlineitem;
}

public QuoteLineItem getQuoteLineItem1() {

return qutlineitem1;
}
public Quote getQuote1() {

return quote1;
}

//Editin Contact Details......

public PageReference tochange() {

Id Id = ApexPages.currentPage().getParameters().get('Id');
Enable='edit2';
System.debug('##############visible###############'+visible);
return null;

}

//Saving contact details
public PageReference toupdatecontact() {

Id Id = ApexPages.currentPage().getParameters().get('Id');
PageReference samepage=new PageReference('/apex/pcontactdetail?id='+id);
samepage.setRedirect(true);
update contact;
Enable=null;
return null;
}


//opportunity save

public PageReference tosaveOpportunity() {

opt.AccountId = contact.AccountId;
insert opt;
optc.OpportunityId=opt.id;
optc.ContactId=contact.id;
insert optc;
visible=null;
PageReference samepage= new PageReference('/apex/pcontactdetail?id='+id);
samepage.setRedirect(true);
return samepage;
}

 

Error is on insert opt  line....

 

My test method is.....

 

  

private static testmethod void t1() {
Id Id;
test.startTest();
Account act = new Account (Name = 'xyt');
insert act;
Contact con = new Contact( LastName = 'cghj' , AccountId = act.id);
insert con;
// Date myDate = date.newinstance(2018, 2, 17);

Opportunity opttest = new Opportunity(AccountId = act.Id,Name = 'test' , StageName = 'Closed Won', CloseDate = System.today() );
insert opttest;
ApexPages.currentPage().getParameters().put('Id',con.id);

System.debug('#########################OPPORTUNITY################'+opttest.Name);
System.debug('#########################OPPORTUNITY################'+opttest.AccountId);
System.debug('#########################OPPORTUNITY################'+opttest.CloseDate );
System.debug('#########################OPPORTUNITY################'+opttest.StageName );
OpportunityContactRole optctest = new OpportunityContactRole(ContactId = con.id , OpportunityId = opttest.id );
insert optctest ;

............

}

 

So wnat will I do ... Anyone have any suggession please help me... Its urgent...

 

 

Thanks

asish

 

 

 

Hi,

 

i am new to salesforce.

 

i have doubt on collection list

 

1. I need to retrieve records from an object(Ex: Account)

2. Then I have to add those records  to collection LIST dynamically one by one

 

i have use below code But it's giving error So i don't know how to achive it

 

list<string> s = new list<string>();
for (Account tmp : [SELECT name FROM Account order by name])

{
        s.add(tmp);// to add records to list
    system.debug(tmp);
 
}

 

HI

 Am new to salesforce..I  wrote a trigger .it is working fine but now i want to bulkify my trigger...please help me to bulkification.

I am sending the trigger . 

please help me for bulkification.....thanks in advance

 

 

trigger WOW_Block_Time on Appointment__c (before Insert,before update)
{
for(Appointment__c APP : Trigger.new)
{
Time_blocks__c[] TBS = [select id,name,branch__c,date__c,staff__c from Time_blocks__c where Branch__c =:APP.Branch__c AND Date__c =:APP.Appt_Date__c AND RecordTypeId='012O0000000CldF'];

if(TBS.size()>0)
{
App.adderror('Blocked Branch!!');
}

Time_blocks__c[] TBS1 = [select id, name , Branch__c , date__c , staff__c from Time_blocks__c where Branch__c =:APP.Branch__c AND Date__c =:APP.Appt_Date__c AND staff__c =:App.Doctor__c AND RecordTypeId='012O0000000CldK'];

if(TBS1.size()>0)
{
App.adderror('Blocked staff');
}

Time_blocks__c[] TBS2 = [select id,Appt_24_Frm_Hour__c,Appt_24_Frm_Min__c,Apt_24_To_Hour__c,Apt_24_To_Min__c from Time_blocks__c where
Branch__c =:APP.Branch__c AND Date__c =:APP.Appt_Date__c AND staff__c =:App.Doctor__c AND RecordTypeId='012O0000000ClgY'
AND Appt_24_Frm_Hour__c !=:null AND Apt_24_To_Hour__c !=:null ];
if(TBS2.size()>0)
{
for(Time_blocks__c tbs3:tbs2)
{
integer fromhr=integer.valueof(tbs3.Appt_24_Frm_Hour__c);
integer frommin=integer.valueof(tbs3.Appt_24_Frm_Min__c);
integer tohr=integer.valueof(tbs3.Apt_24_To_Hour__c );
integer tomin=integer.valueof(tbs3.Apt_24_To_Min__c);

integer hr=integer.valueof(app.Appt_Hour__c);
integer min=integer.valueof(app.Appt_Minute__c);

if(app.Appt_AM_PM__c=='AM')
{
if((hr>=fromhr &&hr<=tohr&&min>=frommin&&min<=tomin)||(hr>fromhr &&hr<tohr)|| (hr>=fromhr &&hr<tohr&&min>=frommin&&min>=tomin)||(hr>fromhr &&hr<=tohr&&min<=frommin&&min<=tomin))
{
app.adderror('time blocked');
}
}
else if(app.Appt_AM_PM__c=='PM')
{
if(hr==12)
{
hr=12;
}
else
{
hr=hr+12;
}
if((hr>=fromhr &&hr<=tohr&&min>=frommin&&min<=tomin)||(hr>fromhr &&hr<tohr)|| (hr>=fromhr &&hr<tohr&&min>=frommin&&min>=tomin)||(hr>fromhr &&hr<=tohr&&min<=frommin&&min<=tomin))
{
app.adderror('time blocked1');
}

}


}

}

Time_blocks__c[] TBS4 = [select id,date__c from Time_blocks__c where Date__c =:APP.Appt_Date__c AND RecordTypeId='012O0000000ClhH'];

if(TBS4.size()>0)
{
App.adderror('Blocked date');
}


}

}

Hi All,

 

I have a requirement to REWRITE the Salesforce urls to user friendly urls..

Can anyone post the working example on this..

 

This will be more helpfull for doing my task..

 

 

Thanks in Advance..

Praveen K.