• Nishchal Vashisht 1
  • NEWBIE
  • 10 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies

I have implemented SSO among two ORGS. I have made a web services class in my service Org. Can I hit that web service from my Identity provider Org using rest callout? I tried it by making a http get request which for which I use following URL pattern (service Org Url + Urlmap to Web service class) as a response I got 302 status with updated URL, Too handle this I used following code.

while (response.getStatusCode() == 302) {
       request.setEndpoint(response.getHeader('Location'));
        System.debug('END Location isi '+response.getHeader('Location'));
        response = new Http().send(request);
    }
 

I was hitting this point https://cloudce-13a-dev-ed.lightning.force.com/Case/abc but it redirected to https://cloudce-13a-dev-ed.my.salesforce.com/Case

Response of second link comes 404 not found

This is my query.
SOBject acc = [Select Id, Name, (Select Id, Account.Parent.Parent.Name, Name from Contacts__r) from Sales_Location__c where Id ='a005j000009xxxBAxU']; 
Contact abc =(Contact)(acc.getSobjects('Contacts__r')).get(0); System.debug(abc.get('Account.Parent.Parent.Name'));

But instead of using get() if I  directly use abc.Account.Parent.Parent.Name , I am getting result. But I don't know why  my code fails in case of get().  In Actual scenario abc is of SObject type that's why I need to use get() here.

 
import { LightningElement, api, track, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import contactDetails from '@salesforce/apex/GetContact.getContacts';
import addContactRow from '@salesforce/apex/GetContact.addContactRow';
import deleteContactRow from '@salesforce/apex/GetContact.deleteContactRow';
const columns = [
    {
        label: 'Delete',
        type: 'button-icon',
        typeAttributes:
        {
            iconName: 'utility:delete',
            name: 'Delete',
            variant: 'brand',
        }
    },
    {
        label: 'FirstName',
        fieldName: 'FirstName',
        editable: true,
    },
    {
        label: 'LastName',
        fieldName: 'LastName',
        editable: true,
    },
    {
        label: 'Email',
        fieldName: 'Email',
        type: 'email',
        editable: true,
    },
    {
        label: 'Phone',
        fieldName: 'Phone',
        type: 'Phone',
        editable: true,
    },
];

export default class EOperation extends LightningElement {
    data = [];
    columns = columns;
    step = '1';
    @api recordId;
    boolvalue = true;
    emaildata = '';
    subject = '';
    body = '';
    hasError = false;
    error;
    contactObj;
    fldsItemValues = [];
    temp = [];
    secondContact
    @wire(contactDetails, {
        accId: '$recordId'
    }) wiredContacts({ error, data }) {
        if (data) {
            console.log('Temp Data is  ' + data)
            console.log('Stringify data ' + JSON.stringify(data))
            this.contactObj = data;
            this.secondContact = data;
            this.error = undefined;
        } else if (error) {
            console.log('error is ' + error)
            this.error = error;
            this.contactObj = undefined;
        }
    }
handleSave(event) {
        console.log('draft valus ID  ' + JSON.stringify(event.detail.draftValues));
        console.log('  type are ' + typeof (event.detail.draftValues) + '   IS Array ' + Array.isArray(event.detail.draftValues));
        this.temp.push(event.detail.draftValues);
       
        console.log('Temp 0 ' + JSON.stringify(this.temp['id']))
       
        let row = JSON.stringify(event.detail.draftValues).split(',')[1];
        row = row.substring(row.indexOf('-') + 1, row.indexOf('}') - 1)
        console.log('row is  ' + row)
       
        let field = JSON.stringify(event.detail.draftValues).split(',')[0] + '}';
        console.log('ffffis  ' + field)
       
        let fieldValue = field.substring(field.indexOf(':') + 2, field.indexOf('}') - 1);
        console.log('fieldvalue is ' + fieldValue)
        let queryString = '' + field.substring(field.indexOf('{') + 1, field.indexOf('}')) + '';
        console.log('queryString  ' + typeof (queryString))
       
        field = field.substring(field.indexOf('"') + 1, field.indexOf(':') - 1);
        console.log('field is sss ' + field)
       
        let val = this.contactObj[row][field]
        let rs = `"${field}":"${val}"`
       
        console.log('rs is ' + typeof (rs))
        console.log('   IS Array ' + Array.isArray(this.contactObj))
        //let ts1 = this.contactObj.splice(row,1)
        console.log(JSON.stringify(this.contactObj[row]).replace(rs, queryString))
        console.log('tss is  ')
       
        let finall = JSON.parse(JSON.stringify(this.secondContact[row]).replace(rs, queryString));
        //  this.contactObj[row] =JSON.parse(JSON.stringify(this.contactObj[row]).replace(rs,queryString))
       
        console.log(typeof (finall) + '  >>colomn are ' + typeof (this.secondContact[row]))
        this.contactObj[row]=finall;
        //this.secondContact[row]= '[{"Id":"0035j00000MM49HAAT","FirstName":"Alok","LastName":"Thirdss","Phone":"44564754654","Email":"bcd@gmail.com"}]'
        // console.log(ts.replace(rs,queryString))
        //console.log(this.contactObj[row])
        //console.log(this.contactObj[row][field])
        // let temp2 =
        // this.contactObj[row][field] = fieldValue;
    }
}

handelsave is called on oncellchange event in datatable. My Question is why i am getting error on this line 'this.contactObj[row]=finall;'
Actually I have created a datatable with inline edit & I am updating the childobject each time user update any cell.
Here's my datatable. I didn't add full code in JS I have mentioned my Line where I am getting my error. 
<template>
    <div style="height: 300px;">
        <lightning-card title="Contact Details">
            <lightning-button-icon icon-name="utility:adduser" variant="brand" alternative-text="Add user"
                class="slds-m-left_xx-small " slot="actions" title="AddUser" onclick={addUser}>
            </lightning-button-icon>
            <div>
            <lightning-datatable key-field="id" data={contactObj} suppress-bottom-bar hide-checkbox-column="true"
                onrowaction={handleRowActions} oncellchange={handleSave} draft-values={fldsItemValues}  columns={columns}>
            </lightning-datatable>
        </div>
            <p slot="footer">
                <lightning-button-icon icon-name="utility:save" variant="brand" alternative-text="Save"
                    class="slds-m-left_xx-small slds-float_right" title="Save" onclick={saveRecord}>

                </lightning-button-icon>
            </p>
        </lightning-card>


    </div>
</template>

 
This is my VF page.
<apex:page Controller="SaleController" >
    <apex:form >
        <apex:pageBlock title="country list">
            <apex:pageBlockSection columns="3">
                <apex:outputLabel > Countries : </apex:outputLabel>
                <apex:selectList size="1" value="{!selectedCountry}" >
                    <apex:selectOptions value="{!country }"/>
                    <apex:actionSupport event="onchange" action="{!check}" reRender="reg"/>
                </apex:selectList> <br/>
                
                <apex:outputLabel value="Region"/>
                <apex:selectList id="reg" size="1" value="{!selectedRegion}"  >
                    <apex:selectOptions value="{!region }"/>
                    <apex:actionSupport event="onchange" action="{!check}" reRender="stat"/>
                </apex:selectList> <br/>
                
                <apex:outputLabel value="State"/>
                <apex:selectList id="stat" size="1" value="{!selectedState}"  >
                    <apex:selectOptions value="{!state }"/>
                    <apex:actionSupport event="onchange" action="{!check}" reRender="aaa"/>
                </apex:selectList> 
                <br/>
                
            </apex:pageBlockSection>
            
            <apex:pageBlockButtons id="aaa" location="bottom" >
                <apex:commandButton value="Find" action="{!findRecord}" reRender="tab"></apex:commandButton>
            </apex:pageBlockButtons>
            
        </apex:pageBlock>
        
    </apex:form>
    <apex:pageBlock title="Account Record">
        <apex:pageBlockTable id="tab" value="{!listOfAc.contacts}" var="contact" >
            <apex:column value="{!listOfAc.Name}"/>
            <apex:column value="{!contact.FirstName}"/>
            <apex:column value="{!contact.LastName}"/>
            <apex:column value="{!contact.Email}"/>
            <apex:column value="{!contact.Phone}"/>
            
        </apex:pageBlockTable>
        
    </apex:pageBlock>
</apex:page>
And this is my Controller.
public class SaleController {
    
    public List<SelectOption> country {get;set;}
    public List<SelectOption> region {get;set;}
    public List<SelectOption> state {get;set;}    
    
    public String selectedCountry;
    public String selectedRegion;
    public String selectedState;
    
    public String tempCountry;
    public String tempRegion;
    public String tempState;
    
    public Account listOfAc {get;set;}  
    public List<Contact> listOfContact {get;set;} 
    Map<String,List<String>> countryWithState; 
    public SaleController(){
        country=new List<SelectOption>();
        region = new List<SelectOption>();
        state =new List<SelectOption>();
        state.add(new SelectOption('','--None--'));
        
        country.add(new SelectOption('','--None--'));    
        country.add(new SelectOption('India','India'));
        country.add(new SelectOption('China','China'));
        country.add(new SelectOption('US','US'));
        
        
        
        countryWithState = new  Map<String,List<String>>();
        countryWithState.put('IndiaNorth',new List<String>{'Delhi','Jammu','Himachal'});
        countryWithState.put('IndiaSouth',new List<String>{'Kerala','Karnataka'});
        countryWithState.put('IndiaWest',new List<String>{'Sikkim','Manipur','Meghalya'});
        
        countryWithState.put('ChinaNorth',new List<String>{'Hohot','jilin'});
        countryWithState.put('ChinaSouth',new List<String>{'yunan','hainan'});
        countryWithState.put('ChinaWest',new List<String>{'Zehenjang','shanghai'});
        
        countryWithState.put('USNorth',new List<String>{'New York','Washington'});
        countryWithState.put('USSouth',new List<String>{'Texas','Arizona'});
        countryWithState.put('USWest',new List<String>{'Virginia','ohio'});
        
    }
    
    
    public String getSelectedCountry(){
        return selectedCountry;
    }
    
    public void setSelectedCountry(String s){
        tempCountry = s;
        region.add(new SelectOption('','--None--'));
        region.add(new SelectOption('North','North'));
        region.add(new SelectOption('South','South'));
        region.add(new SelectOption('West','West'));
    }
    
    public String getSelectedRegion(){
        return selectedRegion;
    }
    
    public void setSelectedRegion(String s){
        tempRegion=s;
        if(s!=null && this.tempCountry!=null){
            for(String loopString:this.countryWithState.get(this.tempCountry+s)){
                state.add(new SelectOption(loopString,loopString));
            }
        }
    }
    public String getSelectedState(){
        return selectedState;
    }
    public void setSelectedState(String s){
        tempState=s;
    }
    
    
    public String check(){
        return selectedCountry;
    }
    
    public pageReference findRecord(){
        List<Id> listOfId =new List<Id>();
        
        if(tempCountry!=null && tempRegion!=null &&tempState!=null){
            for(Sales_Location__c tempSale:[select Account__c from Sales_Location__c where Country__c=:tempCountry and  State__c=:tempState and Region__c=:tempRegion])
                listOfId.add(tempSale.Account__c);
            
            listOfAc = [Select Name,(Select FirstName,LastName,Phone,Email from Contacts)  from Account where Id In :listOfId limit 1];
        }else{
            System.debug('All thing is Null');
        }
        return null;
    }
    
}


 
Is it possible to make interaction between two triggers ? Suppose I have two different triggers A and B. In A I want to save a List of id who Trigger.new and in other trigger B I want to access that list. Both Trigger are on different object. Is it possible

I have implemented SSO among two ORGS. I have made a web services class in my service Org. Can I hit that web service from my Identity provider Org using rest callout? I tried it by making a http get request which for which I use following URL pattern (service Org Url + Urlmap to Web service class) as a response I got 302 status with updated URL, Too handle this I used following code.

while (response.getStatusCode() == 302) {
       request.setEndpoint(response.getHeader('Location'));
        System.debug('END Location isi '+response.getHeader('Location'));
        response = new Http().send(request);
    }
 

I was hitting this point https://cloudce-13a-dev-ed.lightning.force.com/Case/abc but it redirected to https://cloudce-13a-dev-ed.my.salesforce.com/Case

Response of second link comes 404 not found

Hi, please post me if any one have knowledge on how to merge multiple PDF to one PDF in salesforce. I have gone through the below article but we need J2EE application, i want to setup this with complete Apex with API
Is it possible to make interaction between two triggers ? Suppose I have two different triggers A and B. In A I want to save a List of id who Trigger.new and in other trigger B I want to access that list. Both Trigger are on different object. Is it possible
I'm not sure if I am just completely missing something or no one asks this question but I can't find a solution to this. I have a requirement to be able to upload images into the body of a rich text field which is being used to facilitate back and fourth communication in a SFDC community <> console.

User-added image

I've built a lightning app which works well except I can't figure out how I'm supposed to upload images into the field. Is lightning:inputRichText even capable of doing so? There is no documentation that says it doesn't and it's supposed to replace the legacy ui:richText field (which does not allow for local import anyways). I've also tried the CKEditor approach and that also does not support local import, not to mention with lockerservice enabled it does not render.

Whats weird is the editor we use here allpows for this functionality!!! I'm totally stumped, any help is appreciated.

Here is my component in case it helps:
<aura:component controller="caseCommentsController" implements="force:appHostable,forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global">

  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  <aura:attribute name="comments" type="Case_Comments__c[]"/>
  <aura:attribute name="newComment" type="Case_Comments__c"
         default="{ 'sobjectType': 'Case_Comments__c'
                       }"/>
  
  	<!-- display case comments -->
    <div class="container slds-p-top--medium">
    	<div id="list" class="row">
        	<aura:iteration items="{!v.comments}" var="comment">
            	<c:caseCommentsList comment="{!comment}"/>
            </aura:iteration>
        </div>   
    </div> 

  	<!-- input form using components -->
  	<div class="container slds-p-top--large">
    	<form class="slds-form--stacked">
        	<div class="slds-form-element">
           		<div class="slds-form-element__control">
             		<!-- ui:inputText aura:id="caseid" disabled="true"
                               value="{!v.newComment.Case__c}"/ -->               
            	</div>
          	</div>
         <div class="slds-form-element">
           <div class="slds-form-element__control">
             <lightning:inputRichText aura:id="addComment" 
                                      disabledCategories="FORMAT_FONT"
                                      placeholder="Add a comment..."
                                      value="{!v.newComment.Comment__c}"/>
               <!-- ui:inputRichText aura:id="addComment" required="true" placeholder="Add a comment..."
                               value="{!v.newComment.Comment__c}"/ -->                                
            </div>
          </div>
          <div class="slds-form-element">
          	<ui:button label="Add Comment" 
                       class="slds-button slds-button--neutral"
                       labelClass="label"
                       press="{!c.createComment}"/>
          </div>    
    </form>
  </div><!-- ./container-->
          
</aura:component>

 

Hi there. I'm wondering if anybody in the past has merged 2 or more pdf files using the getContent()

method or something similar? Is this possible?

Thanks

  • February 24, 2009
  • Like
  • 0