• Mahendiran Jayavarma 24
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
Hi Friends,

I am new to integration.  Actually we have differnt record type in a object. When I choose one of the record type , the appropriate type data needs to be stored in other system . it may be SQL server.

Is it possible to insert data into other system from visualforce page and apex ?

Please advise if any solution ?
Thank you.
Hi Friends,

I am new to integration.  Actually we have differnt record type in a object. When I choose one of the record type , the appropriate type data needs to be stored in other system . it may be SQL server.

Is it possible to insert data into other system from visualforce page and apex ?

Please advise if any solution ?
Thank you.
 
Hi, I am getting error and seend SOQL Queries Inside FOR Loops. How to avaoid this. 

  private static void setOwnerToBrandAdmin(List<Contact> newContacts) {
        List<Id> contactIds = new List<Id>();
        for (Contact newContact : newContacts) {
            contactIds.add(newContact.Id);
        }

        
        List<Contact> contacts = [SELECT Id, Brand__c, OwnerId, Owner.Name FROM Contact WHERE Id IN :contactIds];
        List<Contact> contactsToUpdate = new List<Contact>();       
       
        for (Contact contact : contacts) {
            if (contact.Owner.Name == 'Integration') {                
       
                List<Brand_Admin__c> admins = [SELECT User__c FROM Brand_Admin__c WHERE Brand__c = :contact.Brand__c];
                if(admins.size() > 0) {
                    contact.OwnerId = admins[0].User__c;
                    contactsToUpdate.add(contact);
                }
            }
        }

        update contactsToUpdate;
    }
Hi Friends,

I am getting error 'forEach is not a function' error during the page load. Please advise if you have time. Thank you for the help.

Component:

<aura:attribute name="placement"      type="Placement__c" default="{'sobjectType':'Placement__c'}" />
<aura:attribute name="salesOrgCountryCode"          type="String" default="GB"  />

  <aura:iteration items="{!v.errors}" var="error" indexVar="index">
                    <h2>{!error}</h2>
    </aura:iteration>

Component controller.Js

initialise : function( component, event, helper ) {
        helper.cloneRatesHelper(component, event);
        helper.isReadOnly( component )
            .then( function( aPlacements ) {
                component.set( 'v.placement', aPlacements[0] );           
                component.set( 'v.salesOrgCountryCode', aPlacements[0].Placement_Header__r.Sales_Org__r.RegisteredCountryCode__c );      I have null value on this record.
                helper.setupEcmOptions( component );
                return helper.getRegionsList( component );
            } )
           
            .catch( function( error ) {
                helper.handleErrors( component, error );
            } );

    },


Helper Class:

handleErrors: function( component, aErrors ) {

        if ( typeof aErrors === 'string' ) {
            var error = { message : aErrors };
            aErrors = [ error ];
        }

        var aComponentErrors = component.get( 'v.errors' );
        aErrors.forEach( function( error ){                      aErrors.forEach is not a function] Failing descriptor: {markup://c:RateComponent}
            if( error.message ){
               aComponentErrors.push( error.message )
            }

            if( error.pageErrors ) {
                error.pageErrors.forEach( function( pageError ) {
                    aComponentErrors.push( pageError.message );
                } );
            }

            if( error.fieldErrors ) {
                error.fieldErrors.forEach( function( oError, fieldName ) {
                    oError.forEach( function( errorList ) {
                        aComponentErrors.push( "Field Error on " + fieldName + " : " + errorList.message );
                    } );
                } );
            }
        } );
        component.set( 'v.errors', aComponentErrors );
    },
 
Hi ,

I am getting Attempt to de-reference a null object  in production but not in sandbox? is there any clue to fix them.

Class.TriggerClass.setBrandCodeFromPlacementHeader: line 62, column 1 Class.TriggerClass.beforeUpdate: line 14, column 1 Class.BaseTriggerClass.onBeforeUpdate: line 134, column 1 Class.BaseTriggerClass.execute: line 26, column 1 Trigger.CTAInvoiceTrigger: line 4, column 1 13:21:11.0 (175680955)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object

 
Hi Friends,

I am getting error 'forEach is not a function' error during the page load. Please advise if you have time. Thank you for the help.

Component:

<aura:attribute name="placement"      type="Placement__c" default="{'sobjectType':'Placement__c'}" />
<aura:attribute name="salesOrgCountryCode"          type="String" default="GB"  />

  <aura:iteration items="{!v.errors}" var="error" indexVar="index">
                    <h2>{!error}</h2>
    </aura:iteration>

Component controller.Js

initialise : function( component, event, helper ) {
        helper.cloneRatesHelper(component, event);
        helper.isReadOnly( component )
            .then( function( aPlacements ) {
                component.set( 'v.placement', aPlacements[0] );           
                component.set( 'v.salesOrgCountryCode', aPlacements[0].Placement_Header__r.Sales_Org__r.RegisteredCountryCode__c );      I have null value on this record.
                helper.setupEcmOptions( component );
                return helper.getRegionsList( component );
            } )
           
            .catch( function( error ) {
                helper.handleErrors( component, error );
            } );

    },


Helper Class:

handleErrors: function( component, aErrors ) {

        if ( typeof aErrors === 'string' ) {
            var error = { message : aErrors };
            aErrors = [ error ];
        }

        var aComponentErrors = component.get( 'v.errors' );
        aErrors.forEach( function( error ){                      aErrors.forEach is not a function] Failing descriptor: {markup://c:RateComponent}
            if( error.message ){
               aComponentErrors.push( error.message )
            }

            if( error.pageErrors ) {
                error.pageErrors.forEach( function( pageError ) {
                    aComponentErrors.push( pageError.message );
                } );
            }

            if( error.fieldErrors ) {
                error.fieldErrors.forEach( function( oError, fieldName ) {
                    oError.forEach( function( errorList ) {
                        aComponentErrors.push( "Field Error on " + fieldName + " : " + errorList.message );
                    } );
                } );
            }
        } );
        component.set( 'v.errors', aComponentErrors );
    },
 
Hi ,

I am getting Attempt to de-reference a null object  in production but not in sandbox? is there any clue to fix them.

Class.TriggerClass.setBrandCodeFromPlacementHeader: line 62, column 1 Class.TriggerClass.beforeUpdate: line 14, column 1 Class.BaseTriggerClass.onBeforeUpdate: line 134, column 1 Class.BaseTriggerClass.execute: line 26, column 1 Trigger.CTAInvoiceTrigger: line 4, column 1 13:21:11.0 (175680955)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object