• PieterSalesforce
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I have a simple lightining component with following code
Component:
aura:component controller="CheckVATService" implements="force:hasRecordId,force:lightningQuickActionWithoutHeader">
	<aura:attribute name="account" type="Object"/>
    <aura:attribute name="simpleAccount" type="Object"/>
    <aura:attribute name="accountError" type="String"/>
    	
	<force:recordData aura:id="accountRecordLoader"
        recordId="{!v.recordId}"
        fields="VAT_Number__c"
        targetRecord="{!v.account}"
        targetFields="{!v.simpleAccount}"
        targetError="{!v.accountError}"
    />
	<aura:handler name="render" value="{!this}" action="{!c.handleClick}"/>
</aura:component>
Controller .js
({
	handleClick : function(component, event, helper) 
	{
		if (component.get("v.simpleAccount.VAT_Number__c") == null)
		{
			$A.get("e.force:closeQuickAction").fire();
			var resultsToast = $A.get("e.force:showToast");
			resultsToast.setParams({
        	   "title": "VAT Number",
        	   "message": "VAT Number is empty!",
        	   "type": "error",
        	   "key": "error"
			});
			resultsToast.fire();
		}else{
			var action = component.get("c.CallCheckVATService");
			action.setParams(
				{
			        VATNumber: component.get("v.simpleAccount.VAT_Number__c")
				}
			);
		
		    action.setCallback(this, function(a) 
		    {
		        if (a.getState() === "SUCCESS") 
		        {
		           if (a.getReturnValue())
		           {
		        	   $A.get("e.force:closeQuickAction").fire();
			           var resultsToast = $A.get("e.force:showToast");
			           resultsToast.setParams({
			        	   "title": "VAT Number",
			        	   "message": "VAT Number is valid",
			        	   "type": "success",
			        	   "key": "success"
			           });
			           resultsToast.fire();
			       }else{
			    	   $A.get("e.force:closeQuickAction").fire();
			           var resultsToast = $A.get("e.force:showToast");
			           resultsToast.setParams({
			        	   "title": "VAT Number",
			        	   "message": "VAT Number is invalid",
			        	   "type": "error",
			        	   "key": "error"
			           });
			           resultsToast.fire();
			       }
			        
		        } else if (a.getState() === "ERROR") {
		            $A.log("Errors", a.getError());
		        }
		    });
		    $A.enqueueAction(action);
	    }	    
	    
    
	}
})

When I have a value in VAT Number field, the logic is fine, it only shows once a toast message (whether it is valid or not).

But when I added the logic to check for empty VAT Number the toast fires twice.
Any ideas why?

I'm trying to pass step 2 but I think I hit a bug.
2 validations in place:
NOT 
OR ( BillingCountry = "US", BillingCountry ="USA", ISBLANK( BillingCountry ))

NOT( 
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & 
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & 
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & 
"WA:WV:WI:WY", BillingState))

Set both error locations to field (this solved my problem on challenge 1)

In the logs I can see that he is trying to insert BillingState=NYY and it failes on the validation rule (which make sence)

Because of that I get:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: UPYQFGLO
I have a simple lightining component with following code
Component:
aura:component controller="CheckVATService" implements="force:hasRecordId,force:lightningQuickActionWithoutHeader">
	<aura:attribute name="account" type="Object"/>
    <aura:attribute name="simpleAccount" type="Object"/>
    <aura:attribute name="accountError" type="String"/>
    	
	<force:recordData aura:id="accountRecordLoader"
        recordId="{!v.recordId}"
        fields="VAT_Number__c"
        targetRecord="{!v.account}"
        targetFields="{!v.simpleAccount}"
        targetError="{!v.accountError}"
    />
	<aura:handler name="render" value="{!this}" action="{!c.handleClick}"/>
</aura:component>
Controller .js
({
	handleClick : function(component, event, helper) 
	{
		if (component.get("v.simpleAccount.VAT_Number__c") == null)
		{
			$A.get("e.force:closeQuickAction").fire();
			var resultsToast = $A.get("e.force:showToast");
			resultsToast.setParams({
        	   "title": "VAT Number",
        	   "message": "VAT Number is empty!",
        	   "type": "error",
        	   "key": "error"
			});
			resultsToast.fire();
		}else{
			var action = component.get("c.CallCheckVATService");
			action.setParams(
				{
			        VATNumber: component.get("v.simpleAccount.VAT_Number__c")
				}
			);
		
		    action.setCallback(this, function(a) 
		    {
		        if (a.getState() === "SUCCESS") 
		        {
		           if (a.getReturnValue())
		           {
		        	   $A.get("e.force:closeQuickAction").fire();
			           var resultsToast = $A.get("e.force:showToast");
			           resultsToast.setParams({
			        	   "title": "VAT Number",
			        	   "message": "VAT Number is valid",
			        	   "type": "success",
			        	   "key": "success"
			           });
			           resultsToast.fire();
			       }else{
			    	   $A.get("e.force:closeQuickAction").fire();
			           var resultsToast = $A.get("e.force:showToast");
			           resultsToast.setParams({
			        	   "title": "VAT Number",
			        	   "message": "VAT Number is invalid",
			        	   "type": "error",
			        	   "key": "error"
			           });
			           resultsToast.fire();
			       }
			        
		        } else if (a.getState() === "ERROR") {
		            $A.log("Errors", a.getError());
		        }
		    });
		    $A.enqueueAction(action);
	    }	    
	    
    
	}
})

When I have a value in VAT Number field, the logic is fine, it only shows once a toast message (whether it is valid or not).

But when I added the logic to check for empty VAT Number the toast fires twice.
Any ideas why?

I'm trying to pass step 2 but I think I hit a bug.
2 validations in place:
NOT 
OR ( BillingCountry = "US", BillingCountry ="USA", ISBLANK( BillingCountry ))

NOT( 
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & 
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & 
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & 
"WA:WV:WI:WY", BillingState))

Set both error locations to field (this solved my problem on challenge 1)

In the logs I can see that he is trying to insert BillingState=NYY and it failes on the validation rule (which make sence)

Because of that I get:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: UPYQFGLO