• helaCH
  • NEWBIE
  • 10 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
hello i'm new to falesforce i have a class apex to return opportunity of a logged in user and i want to diplay it but it returns empty fields can please somebody help me with it 
here is apex class :
public with sharing class opportunitiesId {
    @AuraEnabled(cacheable=true)
    public static Opportunity getOpportunityByClient() {
       Id userId = UserInfo.getUserId();
       Id  contactId = [SELECT ContactId FROM User WHERE Id = :userId].ContactId;
       Opportunity opportunity=[SELECT Id, Name, InterestRate__c, Tenure__c FROM Opportunity WHERE ContactId = :contactId  LIMIT 1];
       system.debug('hello'+ opportunity );
       return opportunity;
    }} 

and this is js:
import { LightningElement ,api,wire} from 'lwc';
import getOpportunityByClient from '@salesforce/apex/opportunitiesId.getOpportunityByClient';
export default class NegotiateInterestRateAndTenure extends LightningElement {
    @api recordId;
    interestRate;
    tenure;
//tableau de liste   demandes
    @wire(getOpportunityByClient)
    opportunity({ error, data }) {
       
        if (data) {
           
           
            this.interestRate = data.interestRate__c;
            this.tenure = data.tenure__c;
            console.log(data.interestRate__c);
        } else if (error) {
            console.log('error' + error);
           
        }
    }
    connectedCallback(){
        console.log('bonjour');
    }}
 
  • April 19, 2023
  • Like
  • 0
Hello!
I'm new to salesforce  and i need help ,i have a user logged to experience site how can i fetch opportunity id of that user 
  • April 11, 2023
  • Like
  • 0