• Naofumi Kun
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
There is validation that I made but not using a Validation Rule.

Entries with the same Product Name within its Parent Object will be prevented. So for example, a user cannot input 2 ProductA within the Company.

I created this by creating a UNIQUE text field, and have a WF populate this using the LookupID+ProductName.

I already have an existing catch for custom validations, any ideas on how would I insert a catch for this?
 
public void Product(){
   try {
    upsert revenueSchedules;
    }
    catch(System.DmlException e) {
   String S1 = e.getMessage();
        S1 = S1.substringBetween('FIELD_CUSTOM_VALIDATION_EXCEPTION, ' , ': [');
       ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,S1 )); 
    }
}

 
Hi I need your help here.

We need to have schedule.Start_Date__c disabled when schedule.Products_Offer__c == 'Product B'.

Also, I would like to know if it is possible that it will be disabled as soon as I select the Picklist Product B.
 
<apex:actionRegion>
<div class="slds-truncate" title="">
	<apex:inputField style="width:90px;" value="{!schedule.Start_Date__c}" rendered="{!schedule.Products_Offer__c != 'Willow Rail Platform'}">
		<apex:actionSupport event="onchange" rerender="tableId" status="status"/>
	</apex:inputField>
	<apex:outputField style="width:90px;" value="{!schedule.Start_Date__c}" rendered="{!schedule.Products_Offer__c == 'Willow Rail Platform'}">
		<apex:actionSupport event="onchange" rerender="tableId" status="status"/>
	</apex:outputField>
</div>
</apex:actionRegion>
Any kind of help is much appreciated!
 
Hi, 

I am trying to create a Lightning Component to that has a functionality to update a field value(Submit_Go_No_Go_Question__c), and hide the button whenever a field (Go_No_Go_Question__c) is not blank.

Here is my existing code

Apex:
public class addGNGQuestion {
    
    @AuraEnabled
    public static void updateChk(String key){
        Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c, Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];  
        if(acc.Go_No_Go_Question__c == null){
            acc.Submit_Go_No_Go_Question__c = true;
        }
        UPDATE acc;
    }
}

Component:
<aura:component controller="addGNGQuestion"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
    <div class="slds-align_absolute-center" style="height:12rem">
    <lightning:button variant="brand" 
                      label="Add Go-No Go Question" 
                      onclick="{!c.updateCheck}" 
                      aura:id="disablebuttonid" />
        </div>
</aura:component>

Controller:
({
    updateCheck : function(component, event, helper) {
        var rid = component.get("v.recordId");
        var action = component.get("c.updateChk");
        action.setParams({key : rid});
        action.setCallback(this, function(response) {
            var state = response.getState();
            
         let button = component.find('disablebuttonid');  
                 if(acc.Go_No_Go_Question__c != null){
            button.set('v.disabled',true)
            }
            
            if (state === "SUCCESS") {
                $A.get('e.force:refreshView').fire();  
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    isRefreshed: function(component, event, helper) {
        location.reload();
    },
})
Helper:
({
    updateCheck11_helper : function(c,e,h) {
        alert('Success!');
        var save_action = c.get("c.updateCheck");
        save_action.setParams({
            });
        $A.enqueueAction(save_action);
    }
})
Any help is much appreciated.
I created a Lightning Component that will update the value of the field "Submit Go-No Go Question?" from the Opportunity Object.

I created the following:
Apex Class - updateCheckBoxPlan
=================================
public class updateCheckBoxPlan {
@AuraEnabled
public static void updateCheck(){
list Pl_list = new list();
pl_list = [select id,Opportunity.Submit_Go_No_Go_Question__c from Opportunity Limit 1];
Opportunity p =new Opportunity();
p.id=pl_list[0].id;
p.Opportunity.Submit_Go_No_Go_Question__c=true;
update p;
}
}
=================================
Component - Submit
=================================
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" controller="updateCheckBoxPlan">
    <aura:attribute name="updateCheckBox" type="Opportunity" default="{'sobjectType':'Opportunity'}"/>
    <lightning:button variant="brand" label="Confirm" onclick="{!c.updateCheck11}"  />
</aura:component>
=================================
Controller - SubmitGNGController
=================================
({
updateCheck11 : function(c, e, h) {
h.updateCheck11_helper(c,e,h);
},
})
=================================
Helper - SubmitGNGHelper
=================================
({
updateCheck11_helper : function(c,e,h) {
alert('Success!');
var save_action = c.get("c.updateCheck");
save_action.setParams({
});
$A.enqueueAction(save_action);
}
})
=================================

Any help is much appreciated!
Hi I need your help here.

We need to have schedule.Start_Date__c disabled when schedule.Products_Offer__c == 'Product B'.

Also, I would like to know if it is possible that it will be disabled as soon as I select the Picklist Product B.
 
<apex:actionRegion>
<div class="slds-truncate" title="">
	<apex:inputField style="width:90px;" value="{!schedule.Start_Date__c}" rendered="{!schedule.Products_Offer__c != 'Willow Rail Platform'}">
		<apex:actionSupport event="onchange" rerender="tableId" status="status"/>
	</apex:inputField>
	<apex:outputField style="width:90px;" value="{!schedule.Start_Date__c}" rendered="{!schedule.Products_Offer__c == 'Willow Rail Platform'}">
		<apex:actionSupport event="onchange" rerender="tableId" status="status"/>
	</apex:outputField>
</div>
</apex:actionRegion>
Any kind of help is much appreciated!
 
Hi, 

I am trying to create a Lightning Component to that has a functionality to update a field value(Submit_Go_No_Go_Question__c), and hide the button whenever a field (Go_No_Go_Question__c) is not blank.

Here is my existing code

Apex:
public class addGNGQuestion {
    
    @AuraEnabled
    public static void updateChk(String key){
        Opportunity acc = [SELECT Id, Name, Submit_Go_No_Go_Question__c, Go_No_Go_Question__c FROM Opportunity WHERE Id=:key];  
        if(acc.Go_No_Go_Question__c == null){
            acc.Submit_Go_No_Go_Question__c = true;
        }
        UPDATE acc;
    }
}

Component:
<aura:component controller="addGNGQuestion"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
    <div class="slds-align_absolute-center" style="height:12rem">
    <lightning:button variant="brand" 
                      label="Add Go-No Go Question" 
                      onclick="{!c.updateCheck}" 
                      aura:id="disablebuttonid" />
        </div>
</aura:component>

Controller:
({
    updateCheck : function(component, event, helper) {
        var rid = component.get("v.recordId");
        var action = component.get("c.updateChk");
        action.setParams({key : rid});
        action.setCallback(this, function(response) {
            var state = response.getState();
            
         let button = component.find('disablebuttonid');  
                 if(acc.Go_No_Go_Question__c != null){
            button.set('v.disabled',true)
            }
            
            if (state === "SUCCESS") {
                $A.get('e.force:refreshView').fire();  
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } 
                else {
                    console.log("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    isRefreshed: function(component, event, helper) {
        location.reload();
    },
})
Helper:
({
    updateCheck11_helper : function(c,e,h) {
        alert('Success!');
        var save_action = c.get("c.updateCheck");
        save_action.setParams({
            });
        $A.enqueueAction(save_action);
    }
})
Any help is much appreciated.