0

I am trying to update the records using the update button in Visual force page. Based on the values provided in the visual force page the values should me updated on the object. I Using

( System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Error is in expression '{!updateClientRelShip}' in component in page clientvisitreports updateClientRelShip: line 150, column 1 )

Visual force page :

<apex:pageBlockTable value="{!tpCliMap[key]}" var="a" columns="5" title="Client Details">
                <apex:column value="{!a.Client__c}" headerValue="Client Name" style="width:10%"/>
                    <apex:column headerValue="Relationship Type" >
                        <apex:inputField value="{!a.Relationship_Type__c}" label="Relationship Type">
                            <apex:param assignTo="{!relShipType}" value="{!a.Relationship_Type__c}" name="Type"/>
                        </apex:inputField>
                    </apex:column>
             <apex:column headerValue="Relationship Grade" >
                        <apex:inputField value="{!a.Relationship_Grade__c}">                     
                            <apex:param assignTo="{!relShipGrade}" value="{!a.Relationship_Grade__c}" name="Grade"/>
                        </apex:inputField>
            </apex:column>
            <apex:column headerValue="Action" style="width:5%">
                    <apex:commandButton value="UPDATE" action="{!updateClientRelShip}">
                        <apex:param assignTo="{!relShipId}" value="{!a.Id}" name="Yogi"/>
                    </apex:commandButton>
            </apex:column>

Class :

public with sharing class MatrixPageContoller {
public String currentRecordId {get;set;}
public List<Client_Visit_Report__c> cvrLst;
public List<Id> tpLst;
public List<Id> clientLst;
public List<Client_Relationships__c> cliRel;
public Map<string, List<Client_Relationships__c>> tpCliMap{get;set;}
public Client_Relationships__c crel{get;set;}
public string selectedvalue1{get;set;}
public string selectedvalue2{get;set;}
public list<Contact> ConList {get;set;}
public id relShipId {get;
                    set {
                        relShipId = value;            
                        }
                    }
public string relShipType{get;
                            set {
                                relShipType= value;  
                                system.debug('===============>'+relShipType);          
                                } 
                         }
public string relShipGrade{get;
                            set {
                                relShipGrade= value;            
                                }
                         }
public String newGrade{get;

        set {
            newGrade = value;

        }
    }
//System.debug('============Id=============>>'+relShipId);
       // System.debug('=============Type============>>'+relShipType);
        //System.debug('=============Grade============>>'+relShipGrade);

    public MatrixPageContoller(ApexPages.StandardController controller) {
        relShipId = ApexPages.CurrentPage().getparameters().get('Yogi');
        relShipType = ApexPages.CurrentPage().getparameters().get('Type');
        relShipGrade = ApexPages.CurrentPage().getparameters().get('Grade');

        //selectedvalue2 = '(A) I can pick the phone up to this contact right now and discuss a contentious issue';
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        system.debug('PSM1 '+ currentRecordId);
        cvrLst = new List<Client_Visit_Report__c>([Select id,(Select Id, TP_Personnel__c From TP_Attendee__r), (Select Id, Contact_Name__c From Client_Attendees__r) From Client_Visit_Report__c where id =: currentRecordId ]);
        ConList = [SELECT Id,name,TP_Client__c FROM contact WHERE RecordTypeId in (SELECT Id FROM RecordType WHERE Name = 'Client')];
        system.debug('PSM2 '+ cvrLst);
        tpLst = new List<Id>();
        clientLst = new List<Id>();
        crel = new Client_Relationships__c();
        for(Client_Visit_Report__c cv: cvrLst){
            for(TP_Attendees__c tp: cv.TP_Attendee__r){
                tpLst.add(tp.TP_Personnel__c);
            }

            for(Client_Attendee__c ca: cv.Client_Attendees__r){
                clientLst.add(ca.Contact_Name__c);
            }

        }
        system.debug('PSM3 '+ clientLst.size()+ clientLst);
        system.debug('PSM4 '+ tpLst.size()+ tpLst);
        cliRel = new List<Client_Relationships__c>([select id,Grade_Index__c, TP_Employee__r.Name, Client__c, Relationship_Grade__c,Relationship_Grade_2__c,Previous_Grade__c, Relationship_Type__c from Client_Relationships__c where Client__c in:clientLst and TP_Employee__c in: tpLst]);
        system.debug('PSM5 '+ cliRel.size());
        tpCliMap = new Map<string, List<Client_Relationships__c>>();

        for(Client_Relationships__c cr: cliRel){
            If(!tpCliMap.containsKey(cr.TP_Employee__r.Name)){
                system.debug('Inside for if '+ cr);
                tpCliMap.put(cr.TP_Employee__r.Name, New List<Client_Relationships__c>());
            }
                system.debug('Inside for else '+ cr);
                tpCliMap.get(cr.TP_Employee__r.Name).add(cr);

        }

        system.debug('tpCliMap '+ tpCliMap.values());

    }

    public void updateClientRelShip(){
        relShipId = System.currentPageReference().getParameters().get('Yogi');
        string relShipType = ApexPages.CurrentPage().getparameters().get('Type');
        string relShipGrade = ApexPages.CurrentPage().getparameters().get('Grade');
        System.debug('============Id=============>>'+relShipId);
        System.debug('=============Type============>>'+relShipType );
        System.debug('=============Grade============>>'+relShipGrade );
        Client_Relationships__c clientRelationShip = new Client_Relationships__c (id=relShipId,Relationship_Type__c = relShipType ,Relationship_Grade__c = relShipGrade);

        update clientRelationShip;
    }

}`
2
  • remove assignedTo in your apex:param and verify relShipId value
    – Himanshu
    Aug 1 '16 at 8:00
  • Now i am not Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id. However when i am clicking on the update button .. Only Id is getting passed the new values are not getting updated in the record.. USER_DEBUG DEBUG|============Id=============>>a0X28000001Ag1qEAC DEBUG|=============Type============>>null DEBUG|=============Grade============>>null Aug 1 '16 at 12:36
0

You need to set all the apex:param inside the apex:commandButton.

By doing this, you can able to access type and grade inside the apex method.

<apex:commandButton value="UPDATE" action="{!updateClientRelShip}" reRender="Your Panel">
        <apex:param assignTo="{!relShipId}" value="{!a.Id}" name="Yogi"/>
        <apex:param assignTo="{!relShipType}" value="{!a.Relationship_Type__c}" name="Type"/>
        <apex:param assignTo="{!relShipGrade}" value="{!a.Relationship_Grade__c}" name="Grade"/>
<apex:commandButton>
0

Create a hidden output panel on the page, and simply rerender it. This will cause the command button to set the controller vairable as expected.

 <apex:commandButton value="UPDATE" action="{!updateClientRelShip}" reRender="Your Panel">
        <apex:param assignTo="{!relShipId}" value="{!a.Id}" name="Yogi"/>

1
  • Thanks Anjuna... Now i am not Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id. However when i am clicking on the update button .. Only Id is getting passed the new values are not getting updated in the record.. USER_DEBUG DEBUG|============Id=============>>a0X28000001Ag1qEAC DEBUG|=============Type============>>null DEBUG|=============Grade============>>null Aug 1 '16 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.