• amateur1
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 51
    Questions
  • 40
    Replies

hi i have displayed some strings in visualforce page

 

aaaaa-------ggggggggg----------hhhhh it is completely one string

aaaaa-------ddddddddd-----------kkkk   it is completely one string only

 

the values are complete strings

 

 

 

instead of that can i make it into tables like

 

aaaa|gggggg|hhhh

aaaa|dddddd|kkkk

 

 

hi i  have created a map like map<date__c,list<string>

 

now for every key i am getting list values but in visual force page the list is getting displayed in a colum way can i break the list into rows

hi i have created a map with date as key and string as values.now i want the values to be displayed according to date ascending order how can i order by my key in the map

hi i have two queries for two non relational objects . they have same fields date for both 

 

now in my map i want to put a key when retrieved should get the records from both the objects that are having the same date

hi 

I have two non related objects for which i have written two queries  i want to display the two query results in only one table in visual force page  how can i do that both the queries will have the same item and ware house equal that is the only relation i have

Fulfillment__c f=[select id,item__c  from Fulfillment__c where item__c=:userinput.item__c and warehouse__c=:userinput.warehouse__c ];

 

 

Goods_Received_Note_Line_Item__c grnli=[select id,item__c,warehouse__c from Goods_Received_Note_Line_Item__c where item__c=:userinput.item__c and warehouse__c=:userinput.warehouse__c

hi here i am creating a map and i have 6 values in the query but only the last value is getting into the map. how to get all the 6 values

 

for(ROI_Visualization_Calulator_Line_Item__c rvc:[select id,name,ROI_Visualization__c from ROI_Visualization_Calulator_Line_Item__c where ROI_Visualization__c in:trigger.newmap.keyset()])
{
mapRoi.put(rvc.ROI_Visualization__c ,rvc);

}


i have wriiten a query how i can give this value in test case

 

ISRList = [SELECT id,name,Date__c,Item__c,Warehouse__c,Qty_Returned__c
FROM Item_Supplier_Return__c WHERE CREATEDDATE=LAST_MONTH];

hi all 

 

i have written this trigger and i tried to bulkify it using sets and maps and i tried with 100 percent effort on it to bulkify it but couldnt do it because i have minimum knowledge on how to use maps please some on if u r patient enough re write my code and please comment so i will be able to understand how to bulkify a trigger and  especially how to use maps please dont give me reference links as i already read all those but could gain minimum knowledge and couldnt use it to bulkify my trigger

 

trigger WOW_Block_Time on Appointment__c (before Insert,before update)
 {
for(Appointment__c APP : Trigger.new)
{

Time_blocks__c[] TBS2 = [select id,Branch__c,Date__c,Staff__c,RecordTypeId,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 or Branch__c =:null)  AND (Date__c =:APP.Appt_Date__c or Date__c=:null)  AND 
(staff__c =:App.Doctor__c or staff__c=:null) AND
(RecordTypeId='012O0000000ClgY' or RecordTypeId='012O0000000CldK' or RecordTypeId='012O0000000CldF' or RecordTypeId='012O0000000ClhH')
AND (Appt_24_Frm_Hour__c !=:null or Appt_24_Frm_Hour__c=:null)  AND  (Apt_24_To_Hour__c !=:null or Apt_24_To_Hour__c=:null) ];

for(Time_blocks__c TBS3:TBS2)
{

if(tbs3.Branch__c ==APP.Branch__c && tbs3.Date__c==APP.Appt_Date__c && tbs3.staff__c ==null && tbs3.Appt_24_Frm_Hour__c ==null &&tbs3.Apt_24_To_Hour__c ==null &&
tbs3.RecordTypeId=='012O0000000CldF')
{
if(TBS2.size()>0)
{
App.adderror('Blocked Branch!!');
}
}

if(tbs3.Branch__c ==APP.Branch__c && tbs3.Date__c==APP.Appt_Date__c && tbs3.staff__c ==App.Doctor__c&& tbs3.Appt_24_Frm_Hour__c ==null &&tbs3.Apt_24_To_Hour__c ==null &&
tbs3.RecordTypeId=='012O0000000CldK')
{
if(TBS2.size()>0)
{
App.adderror('Blocked staff!!');
}
}

if(tbs3.Branch__c==null && tbs3.Date__c==APP.Appt_Date__c && tbs3.staff__c==null&& tbs3.Appt_24_Frm_Hour__c==null &&tbs3.Apt_24_To_Hour__c ==null &&
tbs3.RecordTypeId=='012O0000000ClhH')
{
if(TBS2.size()>0)
{
App.adderror('Blocked Date!!');
}
}

if(tbs3.Branch__c ==APP.Branch__c && tbs3.Date__c==APP.Appt_Date__c && tbs3.staff__c ==App.Doctor__c&& 
tbs3.Appt_24_Frm_Hour__c !=null &&tbs3.Apt_24_To_Hour__c!=null &&
tbs3.RecordTypeId=='012O0000000ClgY')
{
if(TBS2.size()>0)
{
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');
}

}


}

}


}

}
}



hi 

 

i have a piclist field where in i have given numbers from 1 to 10 now i want to access the integer values of the piclist how can i do that

hi all

 

i have tried to put some values into a picklist but the diplay i am getting is a full text field with scroll bar i dont want all the values to apeer fully i want it to be lika a picklist field whre in we can select the paricular option

 

 


<apex:column headerValue="lot number piclist">

<apex:selectlist >
<apex:selectOptions value="{!wrapper.options}" />
</apex:selectlist>

</apex:column>

hi i am new to bulkification please help me bulkify this trigger

 

 

/*This trigger creates Custom Revenue Schedules depending

on the size of opportunitylineitemschedule when a opportunity line item is updated*/

 

trigger CreateCloneScheduleRevenue on OpportunityLineItem (after update)
{

//creating new list of custom revenue schedules
public list<Custom_Revenue_Schedule__c > CRSSList {get;set;}
CRSSList =new list<Custom_Revenue_Schedule__c >();


//initializing set of pricebookid's
set<id> pricebookid=new set<id>();


//initializing set of opporunitylineitemid's
set<id> oliid=new set<id>();


id opp;


//adding the pricebookentryid and opportunitylineitem id'd to the set
for(opportunitylineitem ols:trigger.new)
{
pricebookid.add(ols.pricebookentryid);
oliid.add(ols.id);
opp=ols.opportunityid;
}


//retriveing pricebookentryid
pricebookentry pbe=[select id,Product2Id from pricebookentry where id=:pricebookid];


//retrieving product2 id
product2 p2=[select id from product2 where id=:pbe.product2id];

Custom_Revenue_Schedule__c[] c=[select id from Custom_Revenue_Schedule__c where Product__c=:p2.id];
//deleting the custom revenue schedules if size is greater than 0
if(c.size()>0)
{
delete c;
}


//creating new custom revenue schedules depending on the size of opportunitylineitemschedule
opportunitylineitemschedule[] olsc=[select id,Quantity,Revenue,ScheduleDate from opportunitylineitemschedule where opportunitylineitemid=:oliid];

for(opportunitylineitemschedule olsc1:olsc)
{
Custom_Revenue_Schedule__c c1=new Custom_Revenue_Schedule__c();
c1.Schedule_Revenue__c=olsc1.Revenue;
c1.Date__c=olsc1.ScheduleDate;
c1.Opportunity__c=opp;
c1.Product__c=p2.id;
CRSSList .add(c1);
}

insert CRSSList ;
}

how to write test case for this class

 

 

global class WOW_InventoryAgeing implements schedulable
{
    global void execute(SchedulableContext sc)
    {
   WOW_InventoryAgeing_BatchClass b1 = new WOW_InventoryAgeing_BatchClass(); //ur batch class
      database.executebatch(b1,180);
    }
    
     
}

this is the trigger i have written i know bulkification for singl queries but i am still confused for multiple query bulkification of trigger please check my trigger and give me bulkification code for it

 

 

trigger CreateCloneScheduleRevenue on OpportunityLineItem (after update)
{
public list<Custom_Revenue_Schedule__c > n1 {get;set;}
n1 =new list<Custom_Revenue_Schedule__c >();
set<id> pricebookid=new set<id>();
set<id> oliid=new set<id>();
id opp;
for(opportunitylineitem ols:trigger.new)
{
pricebookid.add(ols.pricebookentryid);
oliid.add(ols.id);
opp=ols.opportunityid;
}
pricebookentry pbe=[select id,Product2Id from pricebookentry where id=:pricebookid];
product2 p2=[select id from product2 where id=:pbe.product2id];
Custom_Revenue_Schedule__c[] c=[select id from Custom_Revenue_Schedule__c where Product__c=:p2.id];
if(c.size()>0)
{
delete c;
}
opportunitylineitemschedule[] olsc=[select id,Quantity,Revenue,ScheduleDate from opportunitylineitemschedule where opportunitylineitemid=:oliid];
for(opportunitylineitemschedule olsc1:olsc)

{
Custom_Revenue_Schedule__c c1=new Custom_Revenue_Schedule__c();
c1.Schedule_Revenue__c=olsc1.Revenue;
c1.Date__c=olsc1.ScheduleDate;
c1.Opportunity__c=opp;
c1.Product__c=p2.id;
n1.add(c1);

}


insert n1;
}

i want to write a trigger on opportunitylineitemmschedule in my developer.when a oplischedule is added a new record has to be created .where should i write the trigger on opportunitylineitemschedule i have checked in all s objects but couldnt find the object to write trigger is there a way i can write the trigger directly on opportunitylineitemschedule

how to write trigger on opportunitylineitemschedule.

hi 

i want to write a trigger on opportunitylineitemschedule in my developer account but i am unable to find the object please help me how to find the object so i can write my trigger

hi 

 

 

 

i have a opportunity look up in a visual force page . when i select an opportunity and click on add button the line items of the opportunity should be displayed under it and again the same should be displayed with name and s.no and all in another box in the same page. now when i select another opportunity the line items corresponding should display under clearing the before line items but in the next block the first opp line items and second opp line items both should be diplayed how can i do that

hi 

 

this is the trigger i have written please help me how to bulkify this trigger

 

 

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);
}
}

this is my controller and test case 

 

it got 65 percent plz help

 

 

public class MyChecklist_All
{

public Opportunity[] opp ;
public MyChecklist__c[] chklist{get;set;}
public MyChecklist__c[] chklistapprove{get;set;}
public MyChecklist__c[] chklistrefuse{get;set;}
public MyChecklist__c[] chkrefused{get;set;}
Set<Id> oppid = new Set<Id>();
Public Contact Con {get; set;}
Public Account Ac {get; set;}

public user u{get;set;}
public MyChecklist_All()
{

u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];
Con=[select id,lastname from Contact where id =: u.ContactId];
Ac = [select id,lastname from Account where PersonContactId =: con.Id];
opp=[select id from Opportunity where Accountid=:ac.id];
for(Opportunity aa: opp)
 {
 oppid.add(aa.id);
 } 
chklist=[select id,Name,Product_Checklist__r.name,Approved_On__c,Received__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Active__c=true];
chklistapprove=[select id,Name,Product_Checklist__r.name,Approved_On__c,Received__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Approval_Status__c='Accepted'];
chklistrefuse=[select id,Name,Product_Checklist__r.name,Received__c,Approved_On__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Approval_Status__c != 'Refused' and Approval_Status__c != 'Accepted'];
chkrefused=[select id,Name,Product_Checklist__r.name,Received__c,Approved_On__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Approval_Status__c = 'Refused'];
}



testMethod static void testWebSrvceAddNumbers()
{


account a =new account();
a.Preferred_Delivery_Address__c='Home';
a.E_mail__c='sandeep@tvarana.com';
a.name='dsds';
//a.ts2__Lastname__pc='dds';
insert a;




contact c=new contact();
c.ts2__Lastname__c='dds';
c.LastName='dds';
c.accountid=a.id;
c.CurrencyIsoCode='INR';
insert c;



Profile p = [select id from profile where name='Customer Portal Manager Custom']; 

  User u = new User(alias = 'standt', email='standarduser@testorg.com', 
                  emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US', 
                  localesidkey='en_US', profileid = p.Id, contactid=c.id,
                  timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com'); 
                  
      //  user u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];
         system.runas(u)
         {
         
         account a1 =new account();
a1.Preferred_Delivery_Address__c='Home';
a1.E_mail__c='sandeep@tvarana.com';
a1.name='dds';
//a1.PersonContactId=c.id;
insert a1;
         
                

MyChecklist_All m=new MyChecklist_All();
   }

   

}
}

i have 3 queries in my controller i am able to cover the first query but not able to cover the contact and account queries please look at the queris and help how to cover them

 

 

 

u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];
Con=[select id,lastname from Contact where id =: u.ContactId];
Ac = [select id,lastname from Account where PersonContactId =: con.Id];

hi i have created a map with date as key and string as values.now i want the values to be displayed according to date ascending order how can i order by my key in the map

hi 

I have two non related objects for which i have written two queries  i want to display the two query results in only one table in visual force page  how can i do that both the queries will have the same item and ware house equal that is the only relation i have

Fulfillment__c f=[select id,item__c  from Fulfillment__c where item__c=:userinput.item__c and warehouse__c=:userinput.warehouse__c ];

 

 

Goods_Received_Note_Line_Item__c grnli=[select id,item__c,warehouse__c from Goods_Received_Note_Line_Item__c where item__c=:userinput.item__c and warehouse__c=:userinput.warehouse__c

hi here i am creating a map and i have 6 values in the query but only the last value is getting into the map. how to get all the 6 values

 

for(ROI_Visualization_Calulator_Line_Item__c rvc:[select id,name,ROI_Visualization__c from ROI_Visualization_Calulator_Line_Item__c where ROI_Visualization__c in:trigger.newmap.keyset()])
{
mapRoi.put(rvc.ROI_Visualization__c ,rvc);

}


i have wriiten a query how i can give this value in test case

 

ISRList = [SELECT id,name,Date__c,Item__c,Warehouse__c,Qty_Returned__c
FROM Item_Supplier_Return__c WHERE CREATEDDATE=LAST_MONTH];

hi all

 

i have tried to put some values into a picklist but the diplay i am getting is a full text field with scroll bar i dont want all the values to apeer fully i want it to be lika a picklist field whre in we can select the paricular option

 

 


<apex:column headerValue="lot number piclist">

<apex:selectlist >
<apex:selectOptions value="{!wrapper.options}" />
</apex:selectlist>

</apex:column>

how to write test case for this class

 

 

global class WOW_InventoryAgeing implements schedulable
{
    global void execute(SchedulableContext sc)
    {
   WOW_InventoryAgeing_BatchClass b1 = new WOW_InventoryAgeing_BatchClass(); //ur batch class
      database.executebatch(b1,180);
    }
    
     
}

this is the trigger i have written i know bulkification for singl queries but i am still confused for multiple query bulkification of trigger please check my trigger and give me bulkification code for it

 

 

trigger CreateCloneScheduleRevenue on OpportunityLineItem (after update)
{
public list<Custom_Revenue_Schedule__c > n1 {get;set;}
n1 =new list<Custom_Revenue_Schedule__c >();
set<id> pricebookid=new set<id>();
set<id> oliid=new set<id>();
id opp;
for(opportunitylineitem ols:trigger.new)
{
pricebookid.add(ols.pricebookentryid);
oliid.add(ols.id);
opp=ols.opportunityid;
}
pricebookentry pbe=[select id,Product2Id from pricebookentry where id=:pricebookid];
product2 p2=[select id from product2 where id=:pbe.product2id];
Custom_Revenue_Schedule__c[] c=[select id from Custom_Revenue_Schedule__c where Product__c=:p2.id];
if(c.size()>0)
{
delete c;
}
opportunitylineitemschedule[] olsc=[select id,Quantity,Revenue,ScheduleDate from opportunitylineitemschedule where opportunitylineitemid=:oliid];
for(opportunitylineitemschedule olsc1:olsc)

{
Custom_Revenue_Schedule__c c1=new Custom_Revenue_Schedule__c();
c1.Schedule_Revenue__c=olsc1.Revenue;
c1.Date__c=olsc1.ScheduleDate;
c1.Opportunity__c=opp;
c1.Product__c=p2.id;
n1.add(c1);

}


insert n1;
}

hi 

i want to write a trigger on opportunitylineitemschedule in my developer account but i am unable to find the object please help me how to find the object so i can write my trigger

this is my controller and test case 

 

it got 65 percent plz help

 

 

public class MyChecklist_All
{

public Opportunity[] opp ;
public MyChecklist__c[] chklist{get;set;}
public MyChecklist__c[] chklistapprove{get;set;}
public MyChecklist__c[] chklistrefuse{get;set;}
public MyChecklist__c[] chkrefused{get;set;}
Set<Id> oppid = new Set<Id>();
Public Contact Con {get; set;}
Public Account Ac {get; set;}

public user u{get;set;}
public MyChecklist_All()
{

u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];
Con=[select id,lastname from Contact where id =: u.ContactId];
Ac = [select id,lastname from Account where PersonContactId =: con.Id];
opp=[select id from Opportunity where Accountid=:ac.id];
for(Opportunity aa: opp)
 {
 oppid.add(aa.id);
 } 
chklist=[select id,Name,Product_Checklist__r.name,Approved_On__c,Received__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Active__c=true];
chklistapprove=[select id,Name,Product_Checklist__r.name,Approved_On__c,Received__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Approval_Status__c='Accepted'];
chklistrefuse=[select id,Name,Product_Checklist__r.name,Received__c,Approved_On__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Approval_Status__c != 'Refused' and Approval_Status__c != 'Accepted'];
chkrefused=[select id,Name,Product_Checklist__r.name,Received__c,Approved_On__c,Received_On__c,Specification__c,Received_Document_Remarks__c,Approval_Status__c,Status1__c from MyChecklist__c where Opportunity_Name__c IN: oppid
and Approval_Status__c = 'Refused'];
}



testMethod static void testWebSrvceAddNumbers()
{


account a =new account();
a.Preferred_Delivery_Address__c='Home';
a.E_mail__c='sandeep@tvarana.com';
a.name='dsds';
//a.ts2__Lastname__pc='dds';
insert a;




contact c=new contact();
c.ts2__Lastname__c='dds';
c.LastName='dds';
c.accountid=a.id;
c.CurrencyIsoCode='INR';
insert c;



Profile p = [select id from profile where name='Customer Portal Manager Custom']; 

  User u = new User(alias = 'standt', email='standarduser@testorg.com', 
                  emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US', 
                  localesidkey='en_US', profileid = p.Id, contactid=c.id,
                  timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com'); 
                  
      //  user u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];
         system.runas(u)
         {
         
         account a1 =new account();
a1.Preferred_Delivery_Address__c='Home';
a1.E_mail__c='sandeep@tvarana.com';
a1.name='dds';
//a1.PersonContactId=c.id;
insert a1;
         
                

MyChecklist_All m=new MyChecklist_All();
   }

   

}
}

i have 3 queries in my controller i am able to cover the first query but not able to cover the contact and account queries please look at the queris and help how to cover them

 

 

 

u = [Select id,name ,LastName,FirstName,ContactId,Profile.Name from user where id=:UserInfo.getUserId()];
Con=[select id,lastname from Contact where id =: u.ContactId];
Ac = [select id,lastname from Account where PersonContactId =: con.Id];

this is the controller please help me how to write test case for this

 

 

global class LeadService {
  
   webservice String area; 
   webservice String region; 
   
   //Define an object in apex that is exposed in apex web service
   global class LeadObject {
      webservice String fname;
      webservice String lname;
      webservice String email;
      webservice String phone;
      webservice String city;
      webservice String state;
      webservice String preference;
      webservice String leadId;
   }

   webservice static LeadObject createLead(LeadObject vLead,Travel_History__c THY,Academic_Profiles__c APS,Work_Experience__c WES) {
       
       Travel_History__c TH = new Travel_History__c();
       Academic_Profiles__c AP = new Academic_Profiles__c();
       Work_Experience__c WE = new Work_Experience__c();
       
       Lead lead = new Lead();
       lead.FirstName = vLead.fname; 
       lead.LastName = vLead.lname;
       lead.Email = vLead.email;
       lead.Phone = vLead.phone;
       lead.City = vLead.city;
       lead.State = vLead.state;
       lead.Description = vLead.preference;
       lead.Company = 'None';
       
       insert lead;
       
       TH.Lead__c = Lead.id;
       TH.Name = 'Country';
       Insert TH;
       
       AP.Lead__c= Lead.id;
       Insert AP;
       
       WE.Lead__c= Lead.id;
       WE.Work_Experience_details__c = 'Self';
       WE.name= 'Company';
       WE.Work_Experience_End_Date_MM_YYYY__c = '02/2012';
       WE.Work_Experience_Start_Date__c = '02/2012';
       Insert WE;
        
       
       vLead.leadId = lead.id;
       
       return vLead;
  }
  
  webservice static LeadObject getLead(string leadId) {
      Lead l = [SELECT id, FirstName, LastName, Email, Phone, City, State, Description FROM Lead WHERE id = :leadId];
      
       LeadObject vLead = new LeadObject();
       vLead.fname = l.FirstName; 
       vLead.lname= l.LastName; 
       vLead.email= l.Email; 
       vLead.phone = l.Phone; 
       vLead.city = l.City ;
       vLead.state = l.State; 
       vLead.preference = l.Description;
       vLead.leadId = l.id;

      return vLead;
  }
  
  webservice static LeadObject getLeadByEmailId(string emailId) {
      Lead l = [SELECT id, FirstName, LastName, Email, Phone, City, State, Description FROM Lead WHERE Email = :emailId];
      
       LeadObject vLead = new LeadObject();
       vLead.fname = l.FirstName; 
       vLead.lname= l.LastName; 
       vLead.email= l.Email; 
       vLead.phone = l.Phone; 
       vLead.city = l.City ;
       vLead.state = l.State; 
       vLead.preference = l.Description;
       vLead.leadId = l.id;

      return vLead;
  }  
  webservice static void updateLead(LeadObject vLead) {

       String leadId = vLead.leadId;
       Lead lead = [SELECT id, FirstName, LastName, Email, Phone, City, State, Description FROM Lead WHERE id = :leadId];
       lead.FirstName = vLead.fname; 
       lead.LastName = vLead.lname;
       lead.Email = vLead.email;
       lead.Phone = vLead.phone;
       lead.City = vLead.city;
       lead.State = vLead.state;
       lead.Description = vLead.preference;
       
       update lead;
      

       
       
  }


}

 

hi this is my controller and i am marking red where my test case is not covered

 

 

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];


}
  
}

the error i am getting is

 

System.QueryException: List has no rows for assignment to SObject for contact query 

 

this is my test case

 

@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();
}
}
}




hi 

 

i have written a trigger where i have used list values to update the inventory transactions but with this when i am trying to insert two records at a time i am getting duplicate value error so please help me how to avoid the duplicate value error.i am marking red whre i am using the list value please help resolve the issue

 

trigger Wow_Fulfillment_FIFO_SNUM_LOTNUM on Fulfillement__c (after insert,after update) {

public list<Inventory_Transaction__c> ITList1{get;set;}
ITList1 = new List<Inventory_Transaction__c>();

public list<Inventory_Transaction__c> ITList2{get;set;}
ITList2 = new List<Inventory_Transaction__c>();

public list<Transaction_History__c> THList1{get;set;}
THList1 = new List<Transaction_History__c>();

for(Fulfillement__c FF : Trigger.new)
{
item__c i1 = [select id,Type__c from item__c where id=:ff.item__c];

if(i1.type__c == 'FIFO')
{
Inventory_Transaction__c[] IT = [select id,Item__c,Qty_In__c,Dev_Bucket_Qty_Remaining__c,Qty_Out__c,warehouse__c
from Inventory_Transaction__c where Item__c =:FF.Item__c AND
Warehouse__c =:FF.warehouse__c AND Dev_Bucket_Qty_Remaining__c != 0
Order By Date__c asc];

if(IT.size()==0)
{
ff.Invoice_Line_Item__c.adderror('Records are not available for Quantity to be fullfillment');
}
else
{
Decimal TotalINVqty=0 ;
for(Inventory_Transaction__c IT1:IT)
{
TotalINVqty = TotalINVqty + IT1.Dev_Bucket_Qty_Remaining__c;
system.debug('TotalINVqty:'+TotalINVqty);
}
if(FF.qty_out__c<=TotalINVqty )
{
//If fulfillment qty is same or less than INV transaction first Remaining qty
if(FF.qty_out__c <= IT[0].Dev_Bucket_Qty_Remaining__c)
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = FF.qty_out__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[0].id;
THList1.add(TH);

IT[0].Dev_Bucket_Qty_Remaining__c = IT[0].Dev_Bucket_Qty_Remaining__c-FF.qty_out__c;
IT[0].qty_out__c =IT[0].qty_out__c+FF.qty_out__c;
ITList1.add(IT[0]);
}
else
{
// If fulfillment qty is greater than INV transaction first Remaining qty
Decimal FULFILLEDQTY =0.0;
Decimal REMFULFILLEDQTY =0.0;
FULFILLEDQTY = FF.qty_out__c;
if(FF.qty_out__c >= IT[0].Dev_Bucket_Qty_Remaining__c){
for(integer i =0;i<IT.size();i++)
{
if(FULFILLEDQTY >=0){
REMFULFILLEDQTY = FULFILLEDQTY -IT[i].Dev_Bucket_Qty_Remaining__c;
if(REMFULFILLEDQTY >0)
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = IT[i].Dev_Bucket_Qty_Remaining__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[i].id;
THList1.add(TH);

IT[i].qty_out__c = IT[i].qty_out__c+IT[i].Dev_Bucket_Qty_Remaining__c;
IT[i].Dev_Bucket_Qty_Remaining__c = 0;
FULFILLEDQTY = REMFULFILLEDQTY ;
}
else
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = REMFULFILLEDQTY+IT[i].Dev_Bucket_Qty_Remaining__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[i].id;
THList1.add(TH);

IT[i].qty_out__c =(IT[i].Dev_Bucket_Qty_Remaining__c+REMFULFILLEDQTY)+IT[i].qty_out__c ;
IT[i].Dev_Bucket_Qty_Remaining__c = IT[i].Dev_Bucket_Qty_Remaining__c-FULFILLEDQTY;
FULFILLEDQTY = REMFULFILLEDQTY ;
}
ITList2.add(IT[i]);
}
}
}
}
}
else
{
FF.Invoice_Line_Item__c.addError('Sorry!! "Qty Out" Is not Available to be Fullfilled');
}
}
}


else if(i1.type__c == 'SERIAL NUMBER')
{
Inventory_Transaction__c[] IT = [select id,Item__c,Qty_In__c,Dev_Bucket_Qty_Remaining__c,Qty_Out__c,warehouse__c
from Inventory_Transaction__c where Item__c =:FF.Item__c AND serial_number__c=:ff.serial_number__c
and Warehouse__c =:FF.warehouse__c AND Dev_Bucket_Qty_Remaining__c != 0 and serial_number__c!=null
Order By Date__c asc];
if(IT.size()==0)
{
ff.Invoice_Line_Item__c.adderror('Records are not available for Quantity to be fullfillment');
}
else
{
Decimal TotalINVqty=0 ;
for(Inventory_Transaction__c IT1:IT)
{
TotalINVqty = TotalINVqty + IT1.Dev_Bucket_Qty_Remaining__c;
system.debug('TotalINVqty:'+TotalINVqty);
}
if(FF.qty_out__c<=TotalINVqty )
{
//If fulfillment qty is same or less than INV transaction first Remaining qty
if(FF.qty_out__c <= IT[0].Dev_Bucket_Qty_Remaining__c)
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = FF.qty_out__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[0].id;
THList1.add(TH);

IT[0].Dev_Bucket_Qty_Remaining__c = IT[0].Dev_Bucket_Qty_Remaining__c-FF.qty_out__c;
IT[0].qty_out__c =IT[0].qty_out__c+FF.qty_out__c;
ITList1.add(IT[0]);
}
else
{
// If fulfillment qty is greater than INV transaction first Remaining qty
Decimal FULFILLEDQTY =0.0;
Decimal REMFULFILLEDQTY =0.0;
FULFILLEDQTY = FF.qty_out__c;
if(FF.qty_out__c >= IT[0].Dev_Bucket_Qty_Remaining__c){
for(integer i =0;i<IT.size();i++)
{
if(FULFILLEDQTY >=0){
REMFULFILLEDQTY = FULFILLEDQTY -IT[i].Dev_Bucket_Qty_Remaining__c;
if(REMFULFILLEDQTY >0)
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = IT[i].Dev_Bucket_Qty_Remaining__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[i].id;
THList1.add(TH);

IT[i].qty_out__c = IT[i].qty_out__c+IT[i].Dev_Bucket_Qty_Remaining__c;
IT[i].Dev_Bucket_Qty_Remaining__c = 0;
FULFILLEDQTY = REMFULFILLEDQTY ;
}
else
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = REMFULFILLEDQTY+IT[i].Dev_Bucket_Qty_Remaining__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[i].id;
THList1.add(TH);

IT[i].qty_out__c =(IT[i].Dev_Bucket_Qty_Remaining__c+REMFULFILLEDQTY)+IT[i].qty_out__c ;
IT[i].Dev_Bucket_Qty_Remaining__c = IT[i].Dev_Bucket_Qty_Remaining__c-FULFILLEDQTY;
FULFILLEDQTY = REMFULFILLEDQTY ;
}
ITList2.add(IT[i]);
}
}
}
}
}
else
{
FF.Invoice_Line_Item__c.addError('Sorry!! "Qty Out" Is not Available to be Fullfilled');
}
}
}

if(i1.type__c == 'LOT NUMBER')
{
Inventory_Transaction__c[] IT = [select id,Item__c,Qty_In__c,Dev_Bucket_Qty_Remaining__c,Qty_Out__c,warehouse__c
from Inventory_Transaction__c where Item__c =:FF.Item__c AND lot_number__c=:ff.lot_number__c
and Warehouse__c =:FF.warehouse__c AND Dev_Bucket_Qty_Remaining__c != 0 and lot_number__c!=null
Order By Date__c asc];
if(IT.size()==0)
{
ff.Invoice_Line_Item__c.adderror('Records are not available for Quantity to be fullfillment');
}
else
{
Decimal TotalINVqty=0 ;
for(Inventory_Transaction__c IT1:IT)
{
TotalINVqty = TotalINVqty + IT1.Dev_Bucket_Qty_Remaining__c;
system.debug('TotalINVqty:'+TotalINVqty);
}
if(FF.qty_out__c<=TotalINVqty )
{
//If fulfillment qty is same or less than INV transaction first Remaining qty
if(FF.qty_out__c <= IT[0].Dev_Bucket_Qty_Remaining__c)
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = FF.qty_out__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[0].id;
THList1.add(TH);

IT[0].Dev_Bucket_Qty_Remaining__c = IT[0].Dev_Bucket_Qty_Remaining__c-FF.qty_out__c;
IT[0].qty_out__c =IT[0].qty_out__c+FF.qty_out__c;
ITList1.add(IT[0]);
}
else
{
// If fulfillment qty is greater than INV transaction first Remaining qty
Decimal FULFILLEDQTY =0.0;
Decimal REMFULFILLEDQTY =0.0;
FULFILLEDQTY = FF.qty_out__c;
if(FF.qty_out__c >= IT[0].Dev_Bucket_Qty_Remaining__c){
for(integer i =0;i<IT.size();i++)
{
if(FULFILLEDQTY >=0){
REMFULFILLEDQTY = FULFILLEDQTY -IT[i].Dev_Bucket_Qty_Remaining__c;
if(REMFULFILLEDQTY >0)
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = IT[i].Dev_Bucket_Qty_Remaining__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[i].id;
THList1.add(TH);

IT[i].qty_out__c = IT[i].qty_out__c+IT[i].Dev_Bucket_Qty_Remaining__c;
IT[i].Dev_Bucket_Qty_Remaining__c = 0;
FULFILLEDQTY = REMFULFILLEDQTY ;
}
else
{
Transaction_History__c TH = new Transaction_History__c();
TH.qty_out__c = REMFULFILLEDQTY+IT[i].Dev_Bucket_Qty_Remaining__c;
TH.Fulfillement__c = FF.id;
TH.Inventory_Transaction__c = IT[i].id;
THList1.add(TH);

IT[i].qty_out__c =(IT[i].Dev_Bucket_Qty_Remaining__c+REMFULFILLEDQTY)+IT[i].qty_out__c ;
IT[i].Dev_Bucket_Qty_Remaining__c = IT[i].Dev_Bucket_Qty_Remaining__c-FULFILLEDQTY;
FULFILLEDQTY = REMFULFILLEDQTY ;
}
ITList2.add(IT[i]);
}
}
}
}
}
else
{
FF.Invoice_Line_Item__c.addError('Sorry!! "Qty Out" Is not Available to be Fullfilled');
}
}
}
}
insert THList1;
update ITList1;
update ITList2;
}