+ Start a Discussion
jd123jd123 

save and new is not working ??

 

first time it is working 

I have two object sales Order and Sales Order Item

in sales Order Item Sales Order field is should auto populate but it populating only one time second time onwards the parent sales Order Is not popuating   

public PageReference saveAndNew()
{
insert sa;
//Service__c s=[select id,Name from Service__c where id=:sa.Service__c];
//PageReference p=new PageReference('/apex/ServiceActivity_New?CF00NE000000223mT='+s.Name+'&CF00NE000000223mT_lkid='+sa.Service__c+'&scontrolCaching=1&retURL=%2F'+sa.Service__c+'&sfdc.override=1');
PageReference p= ApexPages.currentPage();
p.setRedirect(true);
return p;
}

 

only one time it is working ??

please help me 

asish1989asish1989

Hi 

   Try this ...

             

public SalesorderItem__c salesorderItem {get;set;}

public Salesorder__c salesorder {get;set;}
   public PageReference functionName(){
          //write some code for
         insert salesorder;
         return null;
    }

         public PageReference saveandnew() {
                 insert salesorderItem;
                String salesorder = salesorderItem.Salesorder__c;
                salesorderItem = new SalesorderItem__c();
                salesorderItem.Salesorder__c = salesorder;
                return null;
        }

 

This may work...

 

 

Did this post answers your questions..if so please mark it solved so that others get benifited...

 

Thanks

asish

jd123jd123

i have tried with code also

what ever values are inserted before those values are not refreshing means previous values displyed as it as

asish1989asish1989

Hi

   Try this...

          

            

public class Test {

     public SalesorderItem__c salesorderItem {get;set;}  

      public Salesorder__c salesorderobj {get;set;}  

      public String salesorder{get;set;}    

 

     public Test() {  

          // your code..   

          if(salesorder !=NULL){     

                 salesorderItem.Salesorder__c = salesorder;   

           }    

       }  

      public PageReference functionName(){   

              //write some code for  

 

              insert salesorderobj;  

              return null;  

       }    

     public PageReference saveandnew() {  

              insert salesorderItem;   

              salesorder = salesorderItem.Salesorder__c;   

              salesorderItem = new SalesorderItem__c();   

            

              return null;

         }   

  }         

 

Did this solve your problem please mark it solved

 

Thanks

asish

jd123jd123

No the same problem i have tried with this also 

if i am giving Sales_Order__c as output then it is working fine 

 

but the url is changing  very big url it is giving  why the url is coming it is more than 10 lines