• Quddus Ololade 4
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 9
    Replies
I am using a custom button having VF behaviour on contail detail page
<apex:page standardController="Contact" extensions="ContactController" action="{!logrecord}" showHeader="false" sidebar="false">
<script type = "text/javascript">
alert(document.location.href);
}
</script>
</apex:page>

The action logrecord is a page reference method return type which navigates to an internal URL.
Once I click the custom button (VF page), How can I refresh the standard contact lightning detail page? I tried with window object and DOM element as well but no luck.

Any suggestions?
Component:
<aura:component controller="LightningController" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global"  >
<aura:attribute name="purposes" type="ApexDataContainer" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    data: {!v.purposes}
</aura:component>
Controller
({
        doInit : function(component, event, helper) {
            var getdata = component.get("c.JsonGetValue");
            getdata.setCallback(this, function(response){      
                var state = response.getState();
                if (state === 'SUCCESS'){
                    var result = response.getReturnValue();
                    console.log('1'+JSON.stringify(result));
                    console.log('2'+result['purposes']);
component.set("v.purposes",response.getReturnValue());
                }
            });
            $A.enqueueAction(getdata);      
        }
    })
Apex:
public class LightningController {

    @AuraEnabled
    public static ApexDataContainer JsonGetValue() {
        ApexDataContainer c1 = new ApexDataContainer();
    System.debug('hello');
        String json1=           '{'+
        ''+
        '    "purposes": ['+
        ''+
        '        {'+
        ''+
        '            "purpose": "service-improvement",'+
        ''+
        '            "legalGround": "ic",'+
        ''+
        '            "status": "not_answered",'+
        ''+
        '            "description": ['+
        ''+
        '                {'+
        ''+
        '                    "language": "sv-EN",'+
        ''+
        '                    "text": "Service data structure"'+
        ''+
        '                }'+
        ''+
        '            ],'+
        ''+
        '            "version": "1.0.0",'+
        ''+
        '            "dataIds": []'+
        ''+
        '        }'+
        '    ]'+
        ''+
        '}';       
        c1 = (ApexDataContainer)JSON.deserialize(json1,ApexDataContainer.class);

        system.debug('wrapper'+c1.purposes.size());
        return c1;
    }
}

In apex debug log, I see that the JSON object has been successfully parsed, while in a lightning controller, I don't get the value in response.getreturnvalue() for this apex method (JsonGetValue) also nothing in the console.log 

I saw in a couple of blogs that we can pass an object from APEX and refer it in lightning controller and component
Can someone help me understand why I am not getting the object in the lightning controller console log
​My component code:
​My component code:

​My component code:

<aura:component controller="AccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global"  >
    <ltng:require styles="/resource/slds221/assets/styles/salesforce-lightning-design-system.min.css" />
    <aura:attribute name="edit" type="Boolean" default="true"/>
    <aura:attribute name="save" type="Boolean" default="false"/>
    <aura:attribute name="cancel" type="Boolean" default="false"/>
    <aura:attribute name="Account" type="Account" default="{ 'sobjectType': 'Account' }"/>
    <aura:attribute name="recordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <center>
        <aura:if isTrue="{!v.edit}">
            <lightning:button variant="neutral" label="Edit Info" class="slds-align_absolute-center" onclick="{!c.handleEdit}"/>
        </aura:if>
        <aura:if isTrue="{!v.save}">
            <lightning:button variant="neutral" label="Save Info" class="slds-align_absolute-center" onclick="{!c.handleSave}"/>
        </aura:if>
        <aura:if isTrue="{!v.cancel}">
            <lightning:button variant="neutral" label="Cancel" class="slds-align_absolute-center" onclick="{!c.handleCancel}"/>
        </aura:if>
    </center>
    <div class="slds-form slds-form_stacked">
        <div class="slds-form-element">
            <div class="slds-form-element__control">
                <lightning:select name="selectItem" label="Process Item" disabled="{!!v.save}">
                    <option value="1">Yes</option>
                    <option value="2">No</option>
                </lightning:select>
            </div>
            <label class="slds-form-element__label" for="input-id-03">Process Contact ?</label>
            Save: {!v.Account.Contact__c}
            <aura:renderIf isTrue="{!v.save}">
                <div class="slds-form-element__control">
                    <force:inputField value="{!v.Account.Contact__c}" class="foo" >{!v.Account.Contact__c}</force:inputField>
                </div>
            </aura:renderIf>
            <aura:renderIf isTrue="{!!v.save}">
                <div class="slds-form-element__control">
                  <force:outputField aura:id="accountLookupOutput" value="{!v.Account.Contact__c}"/>
                </div>
            </aura:renderIf>
        </div>
    </div>
</aura:component>
My Js:
({
    doInit : function(component, event, helper) {
        var getaccountdata = component.get("c.getAccount");
        getaccountdata.setParams({ "Id": component.get("v.recordId")});
        getaccountdata.setCallback(this, function(response){      
            var state = response.getState();
            if (state === 'SUCCESS'){
                console.log(response.getReturnValue());
                component.set("v.Account",response.getReturnValue());
            }
        });
        $A.enqueueAction(getaccountdata);
    }

I  get the associated account data for that account and then I set it back to the account variable attribute.
But on page load, I dont see the value in force:outputfield even though that account has that value populated in the field. Its the standard field so ideally it should have shown the value which is already in the account with the standard view .

Can anyone help me on this? if I missed something here
I also tried to put force:output field at the top as well but still the same its blank on page load
 
Below Code:
public class parentclass{

    public class Model{
        @AuraEnabled public String year {get;set;}
        @AuraEnabled public Map<Integer, Decimal> dataMap {get;set;}
    }
}

Component Code:
<aura:component controller="parentclass" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
   
 <aura:attribute name="listVehicles" type="parentclass.Model[]" />
Error: while saving the component: Failed to save undefined: Invalid <aura:attribute> type: Model

This is speacially on the lightning component API 42 version, I have old component which is on 40 API version works absolutely fine.
Is this is a bug or not the right way to use wrapper any more in lightning ?

Any ideas appreciated !
Thanks

Hi all,

 

Sorry for the newbie questions, but I've been hunting around for some information on how to use JSON in Salesforce and found some good resources however I've still got some questions about how Salesforce can receive a JSON feed from another system and process the results accordingly.

 

The scenario is Salesforce will be receiving a regular feed of master data (finance accounts) from an ERP system. Specifically the quetions I have are:

 

  1. I've found examples that show how to serialise and deserialise JSON messages, however how is the JSON Apex Class exposed so the sending system can deliver it's message?
  2. How is the request authenticated?
  3. How do you map the JSON message onto a Custom Object? Is it simply a case of looping through the message once it's deserialised and insert / upserting into the object?

Any help or pointers gratefully received.