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
Jos Vervoorn 2Jos Vervoorn 2 

Parsing error: Unexpected token case

While creating a 'simple' Lightning QuickAction to update case date/time field I get this unexpected token case.
({
   StartTiming: function(component, event, helper) {
        console.log('save:1');
        var action = component.get("c.case");
        action.setParams({"case": case  });
   }
})
Some help to overcome this would be great. Now the controller is not finished but I need to overcome this issue first.

Many thanks on advance.
 
Best Answer chosen by Jos Vervoorn 2
Alain CabonAlain Cabon
Hi,

The problem is case.

The solution could be: action.setParams({"case": component.get("v.case") });

But without seeing your controllers and your component, it is just a possibility.

 

All Answers

Alain CabonAlain Cabon
Hi,

The problem is case.

The solution could be: action.setParams({"case": component.get("v.case") });

But without seeing your controllers and your component, it is just a possibility.

 
This was selected as the best answer
Jos Vervoorn 2Jos Vervoorn 2
Thanks Alain, that was the trick :)
Jos Vervoorn 2Jos Vervoorn 2
 You do not happen to have a complete example using lightning quick actions to update case date/time field ?  It would be a huge time saver and steep learning curve for me :)
Alain CabonAlain Cabon
"lightning quick actions to update case date/time field."

Where will the button of this quick action be located? 
 
Jos Vervoorn 2Jos Vervoorn 2
It will be on the case page itself. So the idea is to view a case and press a button to set a date/time stamp.
Alain CabonAlain Cabon
The goal is to set the dates wtih predefined field values.(calculated with the current date or other dates) in the form of the quick action?
Jos Vervoorn 2Jos Vervoorn 2
Just current date & time stamp. So one would press the button and a timestamp is set ... as this would trigger another process (process builder) ..
 
Alain CabonAlain Cabon
The problem with a quick action for a case is that you could have already a quick action in the feed tab for a quick creation so the new quick action will be like below and you need a new button "Click to update".
<aura:component controller="CaseLEX" implements="force:lightningQuickAction,force:hasRecordId,force:hasSObjectName">
    <!-- aura:handler name="init" value="{!this}" action="{!c.updateMyCase}" / -->
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="sObjectName" type="String" />
    <aura:attribute name="myCase" type="Case" />
    ===> recordId:<b>{!v.recordId}</b><br/>
    ===> sObjectName:<b>{!v.sObjectName}</b><br/> 
    ===> myCase LastModifiedDate:<b>{!v.myCase.LastModifiedDate}</b><br/> 
    <ui:button aura:id="button" buttonTitle="Click to update" class="button" label="Click to update" press="{!c.updateMyCase}"/>
</aura:component>
 
({
    updateMyCase : function(component, event, helper) {         
        var action = component.get("c.updateCase");
        action.setParams({"caseId": component.get("v.recordId")});      
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS") {
                component.set("v.myCase",response.getReturnValue());
                var resultsToast = $A.get("e.force:showToast");
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Success!",
                    "message": "Case updated."
                });
                toastEvent.fire();
              //  var wasDismissed = $A.get("e.force:closeQuickAction");
              //  wasDismissed.fire();
            } else {
                console.log('Problem updating the case, response state: ' + state);
            }
        });
        $A.enqueueAction(action);   
    }
})
 
public class CaseLEX {
    @AuraEnabled
    public static Case updateCase(String caseId) {
        Case cas = [select id,lastmodifieddate from case where id = :caseId];
        update cas;
        cas = [select id,lastmodifieddate from case where id = :caseId];
        return cas;
    }
}

User-added image
Regards
Jos Vervoorn 2Jos Vervoorn 2
Hi Alain, thanks for your amazing support. You really help me here. !!
Alain CabonAlain Cabon
Ok Good.
tot ziens!