function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VidhiVidhi 

Urgent : Name issue of list element

Hello friends,

 

I amhaving the list of  custom object t which i want to give numbers bt all the time it is giving me list of work order of same name.


public static integer c=0;
public ID QID {get; set;}
public List<ID> ProdList=new List<ID>();
public Work_Orders__c wo = new Work_Orders__c();
public list< Work_Orders__c> wos = new list<Work_Orders__c>();
public list<Work_Orders__c> woinsert = new list<Work_Orders__c>();
public Quote q = new Quote();
Public list<QuoteLineItem> QlIm=new list<QuoteLineItem>();
public list <Work_Schedule__c> wslist=new list<Work_Schedule__c>();
public list <Work_Schedule__c> wslist1=new list<Work_Schedule__c>();
public set<date> datelist=new set<date>();
public List<date> listdate=new List<date>();
integer i;
public void ConvertWorkOrder()
{
QID = ApexPages.currentPage().getParameters().get('ID');
QlIm=[ SELECT ListPrice, PricebookEntryId, Quantity, QuoteId, Id, UnitPrice FROM QuoteLineItem where QuoteId=:QID];
system.debug('@@@@@@@@@@@@@@@@@@'+QlIm);
wslist=[select date__c,product__c,quote__c from Work_Schedule__c where quote__c =:QID and product__c!=null];
system.debug('*****************'+QlIm);
for(Work_Schedule__c w:wslist)
{

datelist.add(w.date__c);
}

for(date d:datelist)
{
listdate.add(d);
}
system.debug('lllllllllllllllllllll'+datelist);
for(i=0;i<listdate.size();i++)
{

for(Work_Schedule__c ws:[select date__c,product__c,quote__c from Work_Schedule__c where quote__C=:QID and date__c=:listdate.get(i)])
{
wslist1.add(ws);
}

}
system.debug('*******List of WOrk Order*********'+wslist1);
integer n=listdate.size();

for(i=0;i<n;i++)
{
system.debug('bbbbbbbbbbbbbbbbbb'+i);

for(quote q : [Select ID, Name, Description, Summary__c, Notes__c, OpportunityID, contactID, Opportunity.AccountId,Opportunity.Location__c from Quote where Id =: QID])
{
string name;
if(q != null)
{
wo.Name =q.name;
wo.Quote__c = q.ID;

}
woinsert.add(wo);

}


}

system.debug('WWWWWWWWWWWWWWWWW'+woinsert);
for(Work_Orders__c won:woinsert )
{
integer k;
k=c;
system.debug('ccccccccccc'+k);
won.name=string.valueOf(k);
wos.add(won);
c++;
system.debug('ooooooooooooooo'+wos);

}




}
}

Jeff MayJeff May

which object are you having problems with?

sf_evolutionsf_evolution

It sounds to me like you're having an issue with the viewstate between the controller and VFP...  This can be difficult without seeing the VFP.

 

The way I have fixed this with selectlists - which can have the same nasty problem of not getting the value to the controller once you enter it in the VFP, is as follows;

 

Define a simple function up in the apex:pageblock of the VFP:

<script>
 function callUpdate(){
     updateCategory('abc');
     }     
</script>

 

In my case "Category" was what had to be updated -- I'm just cutting and pasting some of my code for you... Sorry, you'll have to modify it to your needs.

 

Next,  elsewhere on my VFP I call this javascript&colon;

 

 <apex:SelectList value="{!strMOPId}" size="1" onChange="callUpdate()" multiselect="false">
  <apex:selectOptions value="{!theXMOPItems}"/>
  </apex:SelectList> <br/>

 

...And just calling the javascript call "updateCategory" in the controller, the fields are synched.

 

There of course is an "UpdateCategory" function in the controller - but it just returned the pageref;

 

public PageReference updateCategory() {

  return Apexpages.currentPage();
}

 ...The trick in my particular case was I simply had to notify the controller that the page was "dirty".

If there's a better way to do this, I too am all ears.   I Hope you get more replies, but in the meantime,  I hope this idea helps.