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
Kondal Rao learnerKondal Rao learner 

urgent help

Hi anyone help me about this issue , see i have to two radio buttons name called p-acitivity , c- activity so when i click on p-activity related records has to display and if i select paricular records those reocrds has to move in a list box but its showing error like "ARGUMENT CANNOT BE NULL 1" please tell me what is this error. please anyoen help me this

 

Apex class

public class ActivityOrgdependencyController{

    public String ParentList{set;get;}

    public String ChildList{set;get;}

    private set<id> ChildListW;

    private set<id> parentListW;

    public ActivityOrgdependencyController() {

    idvalue= ApexPages.currentPage().getParameters().get('id');

        Orgname= ApexPages.currentPage().getParameters().get('Org');

        orgidvalue= ApexPages.currentPage().getParameters().get('orgid');

    }

 

    // String orgid = ApexPages.currentPage().getParameters().get('id');

   String orgid;

    public list<Activity_Master__c> ActivityList ;

    public string idvalue {get;set;}

    public string Orgname {get;set;}

    public string orgidvalue {get;set;}

    public ActivityOrgdependencyController(ApexPages.StandardController act)  

    {

         parentListW = new set<id>();

         ChildListW = new set<id>();

     // idvalue= ApexPages.currentPage().getParameters().get('id');

      //  Orgname= ApexPages.currentPage().getParameters().get('Org');

    }

     public string ids{set;get;}

    

    

   public  PageReference ParentSelection()    

   {    system.debug(ids);

       for(activitywrapper awrp: actList){

           awrp.selected=false;

       }

       integer i = Integer.valueof(ids);

       actList[i].selected=true;

      ParentList = OrgNameID+' : '+actList[i].act.CODE__C;

     return null;

    }

    private string OrgNameID;

   private  OrganizationHierarchyMaster__c Org;

   

   public String ind {get;set;}

   {

   ind= '0';

   }

    public List<activitywrapper> getActivityList()

    {  

      

        OrgStructure orgs = new OrgStructure();

        orgid = orgs.temporgId;

        Cookie orgCookie;

        orgCookie = ApexPages.currentPage().getCookies().get('Orgid');

         idvalue= ApexPages.currentPage().getParameters().get('id');

           if(idvalue != null)

        {

            Org = [select name ,OrgName__c, OrganisationLevel__c, OrganisationLevel__r.name from OrganizationHierarchyMaster__c s where id=:idvalue ];

     

           // orgid = orgCookie.getValue();

            orgid = idvalue;

            //ind = '0';

            if(Org .OrganisationLevel__r.Name!=null)

                Orgname = 'Choosed Organisation :'+Org .OrganisationLevel__r.Name +' - ' + Org .Name;

            else

                Orgname = 'Choosed Organisation :' + Org .Name;

        }

        if(Org ==null)

            OrgNameID='';

        else

            OrgNameID=Org .Name;

      

     

        if(orgid != null)

        {

            if(ind == '0')

            {

             

                actList.clear();

                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c

                            where Status__c = 'Active' and id in (Select Activity_Name__c from CT_Org_Activity_Mapping__c

                                                                     WHERE Organisation_Level_Name__c = :orgid )])

                 {

                    actList.add(new activitywrapper(a));

                 }

            }

            else

            {

                actList.clear();

                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c

                            where Status__c = 'Active' and id not in (Select Activity_Name__c from CT_Org_Activity_Mapping__c

                                                                     WHERE Organisation_Level_Name__c = :orgid )])

                 {

                    actList.add(new activitywrapper(a));

                 }  

            }

        }

        else

        {

            if(ind == '0')

            {

          

                actList.clear();

                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c

                            where Status__c = 'Active' and id in (Select Activity_Name__c from CT_Org_Activity_Mapping__c)])

                 {

                    actList.add(new activitywrapper(a));

                 } 

            }

            else

            {

           // ind = '1';

                 actList.clear();

                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c

                            where Status__c = 'Active' and id not in (Select Activity_Name__c from CT_Org_Activity_Mapping__c)])

                 {

                    actList.add(new activitywrapper(a));

                 } 

            }

        }

       return actList;

    }

        //public List<Activity_Master__c> getAlignedActivityList()

  //  {  

  //  system.debug('orgid : ' + orgid );

   //     ActivityList=[Select id,Code__c,Name,Description__c,Frequency__c,Functional__c,Priority__c,Time_Zone__r.name FROM Activity_Master__c

  //                      where Status__c = 'Active' and id not in (Select Activity_Name__c from CT_Org_Activity_Mapping__c

   //                                                              WHERE Organisation_Level_Name__c = :orgid)];       

   //    return ActivityList;

   // }

     List<activitywrapper> actList = new List<activitywrapper>();

    

     public PageReference AssignActivities()

    {

   idvalue= ApexPages.currentPage().getParameters().get('id');

    CT_Org_Activity_Mapping__c orgactmapping;

    try

    {

       // ActivityList.clear();

       if(ind =='0'){

       list<CT_Org_Activity_Mapping__c> orgactmappingList = new list<CT_Org_Activity_Mapping__c>();

        integer i = Integer.valueof(ids);

        actList[i].selected=true;

       for(activitywrapper actwrapper : actList)

              {

                if(actwrapper.selected == true)

                {    system.debug('orgactmapping-->'+orgactmapping);

                     Parentlist = OrgNameID+' : '+actwrapper.act.Code__c;

               

                      orgactmapping = new CT_Org_Activity_Mapping__c();

           orgactmapping.Activity_Name__c = actwrapper.act.id;

            orgactmapping.Organisation_Level_Name__c = idvalue;

            orgactmappingList.add(orgactmapping);

       //insert orgactmapping;

      

               }

              

              }

              insert orgactmappingList;

              system.debug('orgactmappingList-->'+orgactmappingList);

              for(CT_Org_Activity_Mapping__c org:orgactmappingList){

              parentListW.add(orgactmapping.id);

              }

              system.debug('parentListW-->'+parentListW);

      }

      else{

              ChildList= '';

             list<CT_Org_Activity_Mapping__c> orgactmappingList = new list<CT_Org_Activity_Mapping__c>();

           for(activitywrapper actwrapper : actList)

              {

                if(actwrapper.selected == true)

                {

             //   ActivityList.add(actwrapper.act);

                  ChildList +=OrgNameID+' : '+ actwrapper.act.code__c + '\n';

                orgactmapping = new CT_Org_Activity_Mapping__c();

           orgactmapping.Activity_Name__c = actwrapper.act.id;

            orgactmapping.Organisation_Level_Name__c = idvalue;

       orgactmappingList.add(orgactmapping );

               

               }

              }

             

             insert orgactmappingList;

             for(CT_Org_Activity_Mapping__c org:orgactmappingList){

             ChildListW.add(org.id);

            

             }

             }

     

      }          

 

     

    catch(Exception e)

        {

            ApexPages.addMessages(e);

        }

       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Activities assigned successfully'));

       

     return null;

    }

      public PageReference UnAssignActivities()

    {

    try

    {

       // ActivityList.clear();

        system.debug(actList.size());

       for(activitywrapper actwrapper : actList)

      {

        if(actwrapper.selected == true)

        {       

        

         List<CT_Org_Activity_Mapping__c> orgactmapping = [SELECT Id From CT_Org_Activity_Mapping__c where Activity_Name__c = :actwrapper.act.id

                                                                             AND Organisation_Level_Name__c = :orgid];

            delete orgactmapping ;

         

       }

      }

      }

    catch(Exception e)

        {

            ApexPages.addMessages(e);

        }

       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Activities Un-assigned successfully'));

       

     return null;

    }

   

   

    /*Configure Functionality

     desc: Storing Parent activities to CT_Activity_Dependency__c

    */

    public pagereference configure(){

    system.debug('ChildListW-->'+ChildListW);

    system.debug('ParentListW-->'+ParentListW);

    try{

    List<CT_Activity_Dependency__c> Updatelist = new list<CT_Activity_Dependency__c>();

    CT_Activity_Dependency__c dTemp;

    for(id val: ChildListW){

        dTemp = new CT_Activity_Dependency__c ();

        dTemp.Child_Org_Act_Id__c = val;

        Updatelist.add(dTemp);

    }

    for(id val: ParentListW){

        dTemp = new CT_Activity_Dependency__c ();

        dTemp.Parent_Org_Act_Id__c= val;

        Updatelist.add(dTemp);

    }

    system.debug('Updatelist-->'+Updatelist);

    insert Updatelist;

     ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Activities Configured successfully'));

    }

    catch(exception e){

   

        ApexPages.addMessages(e);

    }

    ChildList='';ParentList='';

    return null;

    }

   

    public class activitywrapper

    {

    

        public Activity_Master__c act{get; set;}

        public Boolean selected {get; set;}

        public activitywrapper(Activity_Master__c a)

        {

            act = a;

            selected = false;

        }

    }

   

    }

 

Vf page:

<apex:page controller="ActivityOrgdependencyController" sidebar="true">

 

  <script>

  var valuea ;

  function SubmitValue(val){

  var i = val.lastIndexOf(":")

  val = val.substring(0,i);

  var j =  val.lastIndexOf(":")

  val=val.substring(j+1,i);

  //alert(val);

  valuea =val;

 ParentSelection(val);

 

  }

  function getval(){

 

  return valuea ;

  }

  </script>

    <br />

    <br />

       <apex:pageMessages ></apex:pageMessages>

<apex:form >

 

  <apex:actionFunction name="ParentSelection" action="{!ParentSelection}" rerender="radio1" ><!--status="myStatus" >-->

  <apex:param value="" name="Sample" assignTo="{!ids}"/></apex:actionFunction>

 

<body> 

 

  <apex:pageBlock title="Activity Dependency Configuration" id="pbid">

 <div align="center"> <b> <apex:actionStatus startText="Loading Page....." id="myStatus" startStyle="font-size:20px " onstart="PBtable.hidden=true">

    <apex:facet name="start">

             <apex:outputPanel >

                   <apex:image value="/img/loading32.gif" style="height: 30px;"/>

                   <apex:commandButton value="Processing...Please Wait" style="border-style:none;" status="searchStatus" disabled="true"/>                 

               </apex:outputPanel>            

           </apex:facet>   

    </apex:actionstatus>               

    </b></div>

   

 <table id="Table">

 <tr>

<td style="width: 200px;">

<div style="height: 240px" class="bodyDiv" onclick="resizeFrame();">

        <c:OrgHierarchy currentId1="0" />

    </div>

  

</td>

<td>

<table>

<tr>

<td>

<apex:outputPanel id="radio1">

<div align="center" >

    <apex:selectRadio value="{!ind}" style="align:center"  >

    <apex:selectOption itemValue="0"  itemlabel="Parent Activity" />

    <apex:selectOption itemValue="1"  itemlabel="Child Activity"/>

        <apex:actionSupport event="onclick" rerender="activityView" status="myStatus"/>

      

         </apex:selectRadio>

</div>

<div align="left" >

  <b>  {!orgname}</b>

</div>

</apex:outputPanel>

</td>

</tr>

<tr>

<td>

    <apex:outputPanel id="activityView" >

    <apex:pageBlockTable id="PBtable" value="{!ActivityList}" var="a" rows="3" style="font-size:1.0em;" >

 

    <apex:column width="70px" headerValue="Select">

                <Apex:outputPanel id="radio2" rendered="{!ind=='0'}" > <input type="radio" name="group1" id="radio" onclick="SubmitValue(this.parentNode.id)" /></Apex:outputPanel> <!--<input type="radio" name="group1" onclick="SubmitValue" /> -->

 

                          <apex:inputCheckbox value="{!a.selected}" rendered="{!ind!='0'}" id="checkedone">

                         

                          </apex:inputCheckbox>

                        </apex:column>

                         <apex:column width="70px" headerValue="Code" >

                    <apex:outputText value="{!a.act.Code__c}"></apex:outputText> 

                </apex:column>

                         <apex:column width="300px" headerValue="Name">

                    <apex:outputText value="{!a.act.Name}"></apex:outputText>

                </apex:column>

                                             

                          <apex:column width="400px" headerValue="Description" >

                    <apex:outputText value="{!a.act.Description__c}"></apex:outputText>

                </apex:column>

                    <apex:column width="120px" headerValue="Frequency" >

                    <apex:outputText value="{!a.act.Frequency__c}"></apex:outputText>

                </apex:column>

                    <apex:column width="120px" headerValue="Priority" >

                    <apex:outputText value="{!a.act.Priority__c}"></apex:outputText>

                </apex:column>

                          <apex:column width="120px" headerValue="Functional" >

                    <apex:outputText value="{!a.act.Functional__c}"></apex:outputText>

                </apex:column>

                           <apex:column width="120px"  headerValue="Time Zone" >

                    <apex:outputText value="{!a.act.Time_Zone__r.name}"></apex:outputText>

                </apex:column>

              

              </apex:pageBlockTable>

        </apex:outputPanel>

                 </td>

                  </tr>

                    <tr>

                     <td align="center">

     <apex:commandButton action="{!AssignActivities}"  value="Select" status="myStatus" />

     <apex:commandButton action="{!UnAssignActivities}" value="Remove" status="myStatus"/>

</td>

</tr>

</table>

</td>

<td style="width: 200px;">

          <b>Selected Parents:</b><br/>

          <apex:inputTextarea value="{!ParentList}" readonly="true" rows="4" style="width:100%; height:40%"  /><br/>

          <b> Selected Childs: </b>

            <apex:inputTextarea value="{!ChildList}" readonly="true" rows="6" style="width:100%; height:40%" /><br/>

               <br/>

               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <apex:commandButton status="myStatus" Value="Configure"  action="{!configure}" />

           

        </td>

       

 

</tr>

</table>

 

  </apex:pageBlock>

  </body> 

        </apex:form>

</apex:page>

Dhaval PanchalDhaval Panchal
can you please give exact line no. with code?
Kondal Rao learnerKondal Rao learner

sorry by mistake i accepted that as soluation actually code is saving but while assigining the reocrds it showing error like :" ARUGUMENT 1 CANNOT BE NULL" .  I THINK THERE IS PROBLEM IN THIS AREA I THINK PLEASE CHEKC AND TELL ME VERY URGENT.

 

idvalue= ApexPages.currentPage().getParameters().get('id');
    CT_Org_Activity_Mapping__c orgactmapping;
    try
    {
       // ActivityList.clear();
       if(ind =='0'){
       list<CT_Org_Activity_Mapping__c> orgactmappingList = new list<CT_Org_Activity_Mapping__c>();
        integer i = Integer.valueof(ids);
        actList[i].selected=true;
       for(activitywrapper actwrapper : actList)
              {
                if(actwrapper.selected == true)
                {    system.debug('orgactmapping-->'+orgactmapping);
                     Parentlist = OrgNameID+' : '+actwrapper.act.Code__c;
               
                      orgactmapping = new CT_Org_Activity_Mapping__c();
           orgactmapping.Activity_Name__c = actwrapper.act.id;
            orgactmapping.Organisation_Level_Name__c = idvalue;
            orgactmappingList.add(orgactmapping);
       //insert orgactmapping;
      
               }
              
              }
              insert orgactmappingList;
              system.debug('orgactmappingList-->'+orgactmappingList);
              for(CT_Org_Activity_Mapping__c org:orgactmappingList){
              parentListW.add(orgactmapping.id);
              }
              system.debug('parentListW-->'+parentListW);
      }
      else{
             // ChildList= '';
             list<CT_Org_Activity_Mapping__c> orgactmappingList = new list<CT_Org_Activity_Mapping__c>();
           for(activitywrapper actwrapper : actList)
              {
                if(actwrapper.selected == true)
                {
             //   ActivityList.add(actwrapper.act);
                  ChildList +=OrgNameID+' : '+ actwrapper.act.code__c + '\n';
                orgactmapping = new CT_Org_Activity_Mapping__c();
           orgactmapping.Activity_Name__c = actwrapper.act.id;
            orgactmapping.Organisation_Level_Name__c = idvalue;
       orgactmappingList.add(orgactmapping );
               
               }
              }
             
             insert orgactmappingList;
              for(CT_Org_Activity_Mapping__c org:orgactmappingList){
             ChildListW.add(org.id);
          
             }

                           }
     
      }          

     
    catch(Exception e)
        {
            ApexPages.addMessages(e);
        }
       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Activities assigned successfully'));
       
     return null;
    }

 

Dhaval PanchalDhaval Panchal

Hi,

I am not able to find excact issue, but below is the posible cause. Please check that.

 

When you use integer.ValueOf statement please check null.

 

for example:

If you use below, it will not give any error.

string str='1';
system.debug('###### : ' + integer.valueof(str));

 

But if you use below then, it will give same error which youare facing.

string str=null;
system.debug('###### : ' + integer.valueof(str));

 

So try to check null before using this statement.