• Poorna Developer
  • NEWBIE
  • 50 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 2
    Replies
Helo Everyone,

 I have created two custom field named Amount__c and Connection_Id under the Object 'Order'.

And I have perform callout and get response from the endurl in the form of JSON Data.
Here, the sample JSON file:
 {"data":[{"id":"2911647985786786830357753","connection_id":"291165354723552979434","name":"Simple account 1 MasterCard","nature":"card","balance":2019.4,"currency_code":"EUR", "extra":{ "iban":"DE11100110012612442222",},"created_at":"2020-08-24T05:58:45Z","updated_at":"2021-04-02T07:34:19Z"}

I need to deserialize this file and separate the Balance and connection_id from the json file and store this value in the Amount_c and Connection_Id__c in the 'Order' object.

Is there any suggestion??
Thanks in advance.
Helo Everyone,
  I have written an apex code to get order object data from process builder by using invocable method.
And also I had performed some task like create json data and pass that json data in to webservice to get server resposnse.

Here my code,
public with sharing class OrderActivation
{
     @InvocableMethod(label='getorderid' description='Get order record id from order')
    public static void getdata(getcustomerid[] requests)
    {
        String recordId,bCity,bStreet,bState,bZip,bCountry,sCity,sStreet,sState,sZip,sCountry,orderAmount,cCity,cStreet,cState,cZip,cCountry,cName,cEmail;
         string jsonString;
        for(getcustomerid request : requests)
        {
             recordId=  request.recId;
            System.debug('order Id:::::  '+recordId);            
          RootObject objJSONRoot = new RootObject();  
        Merchant merch = new Merchant();
        merch.signature = '73242ibc7osfsdfb5|tuJEH3gNbeWJsdfsdffIHah||nbobljsdhgfjsdhjbnmdli0poys|doU3HJVosdfsfwefym7MQ44qf7cpn7pc';
        merch.tariff = 10423004;
        Customer cus = new Customer();
        cus.first_name=request.cName;
        cus.last_name=request.cName;
        cus.city=request.cCity;
        cus.sState=request.cState;
        cus.country_code=request.cCountry;
        cus.zip=request.cZip;
        cus.email = request.cEmail;
        cus.customer_ip = '182.156.208.74';
        cus.customer_no = '9265';
        cus.tel ='+49 089 123456';
        cus.mobile = '+49 174 7781423';
        cus.house_no='2';
        Transactions tran = new Transactions();
            tran.payment_type ='INVOICE';
        tran.amount = '100';
        tran.currencyX= 'EUR';
        tran.test_mode='1';
        tran.order_no = '12';  
        Custom cu = new Custom();
        cu.lang='EN';
        objJSONRoot.merchant = merch;
        objJSONRoot.customer = cus;
        objJSONRoot.transactions = tran;
        objJSONRoot.cust = cu;
            
        jsonString = JSON.Serialize(objJSONRoot);
        
        System.debug('jsonString::: ' +jsonString);   
        }
        OrderActivation.OrderGet(recordId,jsonString);
    }
    @future(callout=true)
    public static void OrderGet(string recordId, string jsonString)
    {
          String BodyData = jsonString;
             String OrderId = recordId;
                 System.debug(OrderId);
                    System.debug('Json Body::::'+BodyData);
   
           try
             {
            Order od = new Order(id=OrderId);
             String endpointurl = 'https://sample.webserver';
               Http http = new Http();
            HttpRequest req = new HttpRequest();
            req.setEndpoint(endpointurl);
              //req.setBody(sBody);
            req.setMethod('POST');
            req.setHeader('Accept','application/json');
            req.setHeader('Content-Type', 'application/json');
            req.setHeader('charset','utf-8');
            HttpResponse responseg = http.send(req);
            String response = responseg.getBody();
            System.debug(responseg.getBody());
            System.debug(responseg);
            System.debug(response);     
         
          od.Transaction_Data__c = response;
            update od;  
             
             }
             catch(Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());   
        }
     
 }
    public static string generateJSON(String jsonString, String request)
    {
         
        String first_name = 'Max';
        String last_name ='cName';
       //string email ='test@com';
        string customer_ip = '182.156.208.74';
        string customer_no = '9265';
        string tel ='+49 089 123456';
        string mobile = '+49 174 7781423';
        string payment_type = 'INVOICE';
        string amount = '1000';
        string currencyX = 'EUR';
        string test_mode = '1';
        string due_date = '2021-08-05';
        string invoice_ref = 'BNR-14-8410121284';
        string order_no = '84112121084';
        string lang ='EN';
        String city = 'San Francisco';
        String sState = 'CA';
        String zip = '946556105';
        String country_code = 'US';
        
        RootObject objJSONRoot = new RootObject();
                
       String jsonData = JSON.Serialize(objJSONRoot);
       // jsonData = jsonData.replace('"currency":', '"currencyX":');
      //  System.debug(jsonData);
        return jsonData;
       
    }  
   public class RootObject
    {
        public Merchant merchant { get; set;}
        public Customer customer { get; set;}
        public Transactions  transactions {get;set;}
        public Custom cust {get;set;}
    }
    public class Merchant
    {
        public string signature { get; set; }
        public integer tariff { get; set; }
    }
    
    public class Customer
    {
        public string first_name { get; set; }
        public string last_name { get; set; }
        public string email {get;set;}
        public string house_no {get;set;}
        public string street {get;set;}
        public string city {get;set;}
        public string zip {get;set;}
        public string sState {get;set;}
        public string country_code {get;set;}
        public string customer_ip{get;set;}
        public string customer_no{get;set;}
        public string tel{get;set;}
        public string mobile{get;set;}
        
        
    }
    public class Transactions
    {
        public string payment_type {get;set;}
        public string amount {get;set;}
        public string currencyX {get;set;}
        public string test_mode {get;set;}
        public string due_date {get;set;}
        public string invoice_ref {get;set;}
        public string order_no {get;set;}
            
    }
    public class Custom
    {
        public string lang {get;set;}
    }
    
    public class getcustomerid
    {
         //request billing address related invocable variables and make variables as required one  
          @InvocableVariable(required=true)
            public String recId;//Get Order record id
          @InvocableVariable(required=true)
            public String bStreet;
          @InvocableVariable(required=true)
            public String bState;
          @InvocableVariable(required=true)
            public String bCity;
          @InvocableVariable(required=true)
            public String bZip;
          @InvocableVariable(required=true)
            public String bCountry;
        //request shipping address related invocable varibales and makes variables a required one
          @InvocableVariable(required=true)
            public String sStreet;
          @InvocableVariable(required=true)
            public String sState;
          @InvocableVariable(required=true)
            public String sCity;
          @InvocableVariable(required=true)
            public String sZip;
          @InvocableVariable(required=true)
            public String sCountry;
         //request order amount related invocable varibales and makes variables a required one
          @InvocableVariable(required=true)
            public String orderAmount;
        
       // cCity,cStreet,cState,cZip,cCountry,cName;
        
        @InvocableVariable(required=true)
            public String cCity;
        @InvocableVariable(required=true)
            public String cStreet;
        @InvocableVariable(required=true)
            public String cState;
        @InvocableVariable(required=true)
            public String cZip;
        @InvocableVariable(required=true)
            public String cCountry;
        @InvocableVariable(required=true)
            public String cName;
        @InvocableVariable(required=true)
            public String cEmail;
        
    }
    }

I'm getting error like Future methode cannot call from future method or batch class.

Any help!!
Thanks in advance.
 
Hi Everyone,

I have created a lwc with my custom object name Loan__c and Standard object Contact. Both have look-up relation. When I choose contact name from the list it will the show related loan details in the Loan__c.
User-added image

Once I remove the contact from the field I need to remove Loan data from Loan look-up also.
Is any possible to remove the loan when the contact removed.
Code:
import { LightningElement,track,wire,api } from 'lwc';
import getDetails from '@salesforce/apex/LoanController.getDetails';
import { getRecord } from 'lightning/uiRecordApi';
export default class TransactionDetails extends LightningElement {
@api accountId;
@track display=true;
@track cl='true';
@track aId='true';
@track cId='true';
@track acId='true';
@track cnId='true';
@track cloans= '';
@track selectedLoanId;
@track handleRemovePill;
@track contactname;
@track accountname;
@track _recordId;
@track transaction;
@track loans;
hasRendered=false;
ContactoptionList=[];
isClicked=false;
connectedCallback()
{
this.getLabelDetails();
}
@api
get recordId(){
return this._recordId;
}
set recordId(val){
this._recordId = val;
}
selectedContact(event)
{
debugger;
if(this.isClicked){
this.cloans= ''; // display all the loans
this.aId=true;
this.isClicked=false;
this.contactId='';
if(this.contactId=='' && this.selectedLoanId!='')
{
this.cloans='';
this.selectedLoanId=''; //Clear loan from list
console.log('ok'+this.selectedLoanId);
}
}
else{
this.contactId = event.detail.selectedId;
this.cloans = 'Contact__c=\''+this.contactId+'\'';
this.aId=false;
this.isClicked=true;
}
}

 
Hi Everyone,

I have a object named  'Application__c' and Picklist field named 'Stage__c'['Red', 'Blue','Pink','Black']

Whenever the 'Stage__c'  picklist value is changed I need to track that field value.
ie. When picklist value changed from Red -> Blue I need to track this field in my trigger. Is this possible?
Any help.
Thankyou all.
I have an object called 'Application__c' and field in that called 'Customer_Id__c'.
I need to pass the Customer_Id__c to apex class whenever user enter the data in the object.

User-added image
Apex class
public static void passvalue() { String getcusid; Loan_Application__c lapp = new Loan_Application__c(); getcusid=lapp.Saltedge_Customer_Id__c; System.debug('customerid from sf' +getcusid); }

Trigger to get Customer_Id__c data whenever user given in the object.

User-added image

Is there any idea ?
Thanks.


 
Hi,
From process builder getting record id and pass that in to apex.

User-added image
Apex class to update the record:

public class BacktoQuantum
{
     @InvocableMethod(label='getdata' description='Get data from saltedge')
  public static void toquantum(List<String> ids)
    {
       BacktoQuantum.fromdata(ids);
       //System.debug('callback');
      
  }
   @future(callout=true)
    public static void fromdata(List<String> ids)
   {
         Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setEndpoint('http://ussd.apmuyea.software.com/CustomerAdd_SaltEdge_CallBack.aspx');
            request.setMethod('GET');
            //request.setHeader('Accept','application/json');
            request.setHeader('Content-Type', 'text/html; charset=utf-8');
            request.setBody('{"data": {Saltedge Data }}');
       
            HttpResponse responseg = http.send(request);  
            System.debug(responseg.getBody());
        String ac = responseg.getBody(); //Return JSON data
      List<Loan_Application__c> app =  [Select Amount__c,Rate__c,Term_Months__c from Loan_Application__c where Id=:ids];
       if(!app.isEmpty())
       {
                // app[0];
// To update the JSON data in the first record in the list
       }
        //Loan_Application__c app =  new Loan_Application__c();
       //app.SaltedgeData__c = ac;
       //System.debug('sample json' +app);
         } 
}

The above apex code return a JSON data, I need to store that JSON data in salesforce field called Saltedge__c.
I'm stuck in the update.

can anyone help to me update the record?

Thanks.
Hi Everyone,

I have JSON data. I wish to store this JSON data in my custom object field.
Is this possible in salesforce? Any idea?
Thanks in Advance.

Hi All,

I have a apex code to connect a third party API,

public with sharing class Saltedgelead 
{
    
      @InvocableMethod(label='leadsession' description='Create salt edge lead session')
    public static void leadtest()
        {
            Saltedgelead.geturl();
        }
    public static void geturl()
    { 
        String uri;
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setEndpoint('https://www.saltedge.com/api/partners/v1/lead_sessions/create');
            request.setMethod('POST');
            request.setHeader('Accept','application/json');
            request.setHeader('Content-Type', 'application/json');
            request.setHeader('App-id', 'q_-XTJ_zMjDdH3PiTTSY1q_SbhxYsdfgsg3SB1P3x_9-fJZh8');
            request.setHeader('Secret', 'iBUhgfhgfh6-5dIfUjT3gfNsGrznM-3WQ9ID8UJhMm-8ZsqLGE');
            request.setBody('{"data": {"customer_id": "2911634823132425819231","provider_code": "fake_oauth_client_xf","consent": {"scopes": ["account_details", "transactions_details"]}}}');
            HttpResponse responseg = http.send(request);  
            
         if (responseg.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
            responseg.getStatusCode() + ' ' + responseg.getStatus());
             System.debug(responseg.getBody()); 
              String urli = responseg.getBody();
            Saltedgelead.sendingEmail(urli);
        } 
        else {
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(responseg.getBody());
            uri = (string) results.get('token');
        }
        // return responseg.toString();
           
        //Get
         Http httpg = new Http();
        HttpRequest requestg = new HttpRequest();
       requestg.setEndpoint('https://www.saltedge.com/api/partners/v1/customers/291163482315345819231');
        requestg.setMethod('GET');
        requestg.setHeader('Accept','application/json');
        requestg.setHeader('Content-Type', 'application/json');
       requestg.setHeader('App-id', 'q_-XTJ_zMjDdH3PiTTSY1q_SbhxY3SdsgB1P3x_9-fJZh8');
     requestg.setHeader('Secret', 'iBUdsfgg6-5dIfUjT3gfNsGrznM-3WQ9ID8UJhMm-8ZsqLGE');
       // requestg.setHeader('X-Fern-Token', uri);
        HttpResponse res = http.send(requestg);

        if (res.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
            res.getStatusCode() + ' ' + res.getStatus());
        } else {
            System.debug(res.getBody());
        }   
    }
     public static void sendingEmail(String email) {
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        String[] sendingTo = new String[]{'xxxxxxxx@gmail.com'};
        semail.setToAddresses(sendingTo);
        String[] sendingToBccAdd = new String[]{'xxxxxxxxxx@fernsoftware.com'};
        semail.setBccAddresses(sendingToBccAdd);
        String[] sendingTocAdd = new String[]{'xxxxxxxxxxx@gmail.com'};
        semail.setCcAddresses(sendingTocAdd);
        semail.setSubject('Single Email message Example');
        semail.setPlainTextBody(email);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {semail});
        //return null;
    }
}

Now I'm invoke this apex class in process builder to send the apex output data as a single mail to the user.

When my process builder start runs I get an error like - 
"We can't save this record because the “Saltedge API” process failed. Give your Salesforce admin these details. An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out Error ID: 208143754-77391 (-1742348029"

Is I need to change my code? 
Any idea. 

Thanks all.

Hi all,

I have JSON data like,

{"data":{"id":"448234325073116067","customer_id":"25654656354619231","lead_email":"******2@gmail.com.com","connection_ids":["2911647243243459434"],"status":"initialized","created_at":"2021-03-29T06:41:06Z"}}


I wish to display the above JSON data in lightning record page like a  list view.

Instead of this ,
User-added image

Id - Customer_Id - lead_email - connection_ids - status
448234325073116067 -25654656354619231-******2@gmail.com.com-2911647243243459434-initialized

This there any idea?
Thanks everyone.
Hi,

I have Apex code  output JSON data,

User-added image

I wish to display this json data in my LWC. 
Html:
<template>
    <lightning-card title="Report Data" icon-name="lightning-icon" >
        <div class="slds-m-around_medium">
            <template if:true={lapp}>
                <ul>
               <template for:each={lapp} for:item="app">
                   <li key={app.Id}> {app.Name} </li>
               </template>
            </ul>
           </template>
           <template if:true={error}>
               {error}
           </template>  
        </div>
 </lightning-card>
</template>

Js:
import { LightningElement, wire, track} from 'lwc';
import getURL from '@salesforce/apex/CreateReport.reportgen';
export default class RedirecctedURL extends LightningElement {
       @track lapp;
       @track data;
       @track error;
       wiredActivities;
     @wire(getURL,{
     }
     )
     wiredCases(value){
     this.wiredActivities = value;
     const { data, error } = value;
     
     if(data){
       this.lapp = JSON.stringify(data);
       console.log(JSON.stringify(data));
     
     }else if(error){
       console.log(error);
       this.error = error;
     }
     }
}

Any help??
 
Hi ,
I have the following apex api callout code.
Code:
 public class Saltedgelead 
{
    @AuraEnabled(cacheable=true)
    public static string leadtest()
        {
            Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setEndpoint('https://www.saltedge.com/api/partners/v1/lead_sessions/create?Customer_id=9876541230');
            request.setMethod('POST');
            request.setHeader('Accept','application/json');
            request.setHeader('Content-Type', 'application/json');
            request.setHeader('App-id', 'jbdjhtsfgsdjfbw67uewgruweg6');
            request.setHeader('Secret', 'u7dhsjdf73r8rydhskcnihef73y83');
            request.setBody('{"data": {"customer_id": "9876541230","provider_code": "fake_oauth_client_xf","consent": {"scopes": ["account_details", "transactions_details"]}}}');
            HttpResponse responseg = http.send(request);  
            System.debug(responseg.getBody());
            return responseg.toString();
        } 
}

The above apex code returns a url.
Now I wish to display the return data (Url) in to lwc .
Js:
import { LightningElement, wire, track} from 'lwc';
import getURL from '@salesforce/apex/Saltedgelead.leadtest';
export default class RedirecctedURL extends LightningElement {
    @track lapp;
    @track data;
    @track error;
    @wire (getURL)
    getURL({error,data})
 {
    if (data !== 'undefined') 
    {
        this.lapp = data;
        console.log('Data',data);
    } else if (error) 
    {
        console.log(error);
        this.error = error;
    }
 }
}
html:
<template>
    <lightning-card title="Redirected URL" icon-name="lightning-icon" >
        <div class="slds-m-around_medium">
            <template if:true={lapp}>
                <ul>
               <template for:each={lapp} for:item="app">
                   <li key={app.Id}> {app.Name} </li>
               </template>
            </ul>
           </template>
           <template if:true={error}>
               {error}
           </template>  
        </div>
 </lightning-card>
</template>

But,I get the error like 'Data' is Undefined.
Any idea?
Thanks.


Hi all,

I have an object called (Object1) 'Vechiel' and that has following fields like -  'Age'-(Number) 'Type'-(Picklist) and Max_Term-(Number). 
And one more object called(Object2) - 'Application', which  has 'Age_of_Vehicle'-(Number), FacilityType-(Picklist) and Term(Formula Field).

Whenever I choose Age_of_Vechicle and FacilityType from Application object that need to fetch data from Max_Term(Object 1)  and display in the Term field which is in the Application.

Need forumla field to validate this one, Any help.
Thanks.
Hi,

I need apex (xml) code to upload/Insert address fields in to  account or contact object in salesforce.

ie. in xml I have a code like '<name>Kirk Stevens</name>'+
'<street1>808 State St</street1>'+
'<street2>Apt. 2</street2>'+
'<city>Palookaville</city>'+
'<state>PA</state>'+
'<country>USA</country>'+

after debug this apex code, I want a address field with these address data in account or contact.

Is this possible?
Any help.
Thanks.
Hi, 
I have a decision_matrix__c table with following fields.
Age_of_Vehicle__c,
Max_Term__c,
Vehicle_Type__c by using Age_of_Vehicle__c and Vehicle_Type__c the Max_Term__c will be calculated automatically.
ie. Vechicle_Type='Bike', Age_of_Vehicle__c>=4 then Max_Term__c should be less than 5years.

And, I have another table named 'Vehicle_Application'.
In the 'Vehicle_Application' have fields called - Type_Of_Vehicle and Age_of_vehicle. By given these two values, I need to validate the Term__c field data fetch from 'decision_matrix__c -> Max_Term__c'.
ie. Age_of_vehicle = 3 and Vechicle_Type='bike' and Term__c should be less than which is given in the 'decision_matrix__c -> Max_Term__c'.
(Matrix Search)
Is there any idea?
Thanks.

Need Trigger to validation.

Hi all,
I need apex class to get documentlink field called LinkedEntityId.
This is my create task when document upload.
trigger CreateTask on ContentVersion (after insert) 
{

List<Task> insertTask = new List<Task>();
Task newTask = new Task();
for(ContentVersion newCase : Trigger.new)
{
newTask.subject = 'Document Expiration';
newTask.WhatId = newCase.Id;
newTask.ActivityDate = newCase.Expiry_Date__c;
newTask.ownerId = newCase.OwnerId;
newTask.status = 'Not started';
newTask.Priority = 'Normal';
insertTask.add(newTask);
    if(insertTask.isEmpty())
    {
        try{
            
        }catch(DmlException de)
        {
            System.debug(de);
        }
    }

}

I need to assign LinkedEntityId this id to createTask . Trigger -> WhoId.

Is anyone help?
Thanks in advance.
    

Hi,

I have Apex code  output JSON data,

User-added image

I wish to display this json data in my LWC. 
Html:
<template>
    <lightning-card title="Report Data" icon-name="lightning-icon" >
        <div class="slds-m-around_medium">
            <template if:true={lapp}>
                <ul>
               <template for:each={lapp} for:item="app">
                   <li key={app.Id}> {app.Name} </li>
               </template>
            </ul>
           </template>
           <template if:true={error}>
               {error}
           </template>  
        </div>
 </lightning-card>
</template>

Js:
import { LightningElement, wire, track} from 'lwc';
import getURL from '@salesforce/apex/CreateReport.reportgen';
export default class RedirecctedURL extends LightningElement {
       @track lapp;
       @track data;
       @track error;
       wiredActivities;
     @wire(getURL,{
     }
     )
     wiredCases(value){
     this.wiredActivities = value;
     const { data, error } = value;
     
     if(data){
       this.lapp = JSON.stringify(data);
       console.log(JSON.stringify(data));
     
     }else if(error){
       console.log(error);
       this.error = error;
     }
     }
}

Any help??
 
Hi Everyone,

I have JSON data. I wish to store this JSON data in my custom object field.
Is this possible in salesforce? Any idea?
Thanks in Advance.
Hi,

I have Apex code  output JSON data,

User-added image

I wish to display this json data in my LWC. 
Html:
<template>
    <lightning-card title="Report Data" icon-name="lightning-icon" >
        <div class="slds-m-around_medium">
            <template if:true={lapp}>
                <ul>
               <template for:each={lapp} for:item="app">
                   <li key={app.Id}> {app.Name} </li>
               </template>
            </ul>
           </template>
           <template if:true={error}>
               {error}
           </template>  
        </div>
 </lightning-card>
</template>

Js:
import { LightningElement, wire, track} from 'lwc';
import getURL from '@salesforce/apex/CreateReport.reportgen';
export default class RedirecctedURL extends LightningElement {
       @track lapp;
       @track data;
       @track error;
       wiredActivities;
     @wire(getURL,{
     }
     )
     wiredCases(value){
     this.wiredActivities = value;
     const { data, error } = value;
     
     if(data){
       this.lapp = JSON.stringify(data);
       console.log(JSON.stringify(data));
     
     }else if(error){
       console.log(error);
       this.error = error;
     }
     }
}

Any help??
 

Hi all,
I need apex class to get documentlink field called LinkedEntityId.
This is my create task when document upload.
trigger CreateTask on ContentVersion (after insert) 
{

List<Task> insertTask = new List<Task>();
Task newTask = new Task();
for(ContentVersion newCase : Trigger.new)
{
newTask.subject = 'Document Expiration';
newTask.WhatId = newCase.Id;
newTask.ActivityDate = newCase.Expiry_Date__c;
newTask.ownerId = newCase.OwnerId;
newTask.status = 'Not started';
newTask.Priority = 'Normal';
insertTask.add(newTask);
    if(insertTask.isEmpty())
    {
        try{
            
        }catch(DmlException de)
        {
            System.debug(de);
        }
    }

}

I need to assign LinkedEntityId this id to createTask . Trigger -> WhoId.

Is anyone help?
Thanks in advance.