• HARILAKSHMI M 8
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
public static void PhysicianOnCareTeamAfterOrderStatusUpdate(map<Id, Order> newMap, map<Id, Order> oldMap){
        List<CareTeam__c> mapCaseTeam = new List<CareTeam__c>();
        Set<Id> setOfPhysicianId = new Set<Id>();
        Map<Id, User> mapOfUserId = new Map<Id, User>();
        for(Order objOrder : newMap.values())
        {
            setOfPhysicianId.add(objOrder.implanting_physician__c); 
        }
        for(User user : [SELECT Id, Name, ContactId FROM User WHERE ContactId =: setOfPhysicianId]){
            mapOfUserId.put(user.ContactId, user);
        }
        for(Order objOrder : newMap.values())
        {
            // for permanent type
            if(objOrder.implanting_physician__c != null && objOrder.Type == 'NROP'){
                mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c, 
                                                Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
                                                Roles__c = 'Implanting Physician', 
                                                Status__c = 'Active'));
            }
            // for replacement physician
            else if(objOrder.implanting_physician__c != null && objOrder.Type == 'NREP'){
                mapCaseTeam.add(new CareTeam__c(Patient__c = objOrder.patient_account__c, 
                                                Member__c = mapOfUserId.get(objOrder.implanting_physician__c).Id,
                                                Roles__c = 'Replacement Physician', 
                                                Status__c = 'Active'));
            }
        }
        if(!mapCaseTeam.isEmpty()){
            insert mapCaseTeam;
        }
    }
Hi there,
I wanted to create the OpportunityLineItem record from the the data that is passed from js. I have data in Array of object form.
Please anyone guide me in this, and how i can achieve this,
Below is the required code:
Js code:
let jsonString =[
{
"orderQuantity":"1",
"molexPrice":"1200",
"targetCost":"1150",
"perUnit":"1",
"resalePrice":"1250",
"competitor":"NoPlex",
"ProductName":"LEGEND PLATE, BLANK",
"ProductId":"01t0q000003s2nPAAQ"
},
{
"orderQuantity":"2",
"molexPrice":"1000",
"targetCost":"10000",
"perUnit":"1000",
"resalePrice":"1100",
"competitor":"MyMolex",
"ProductName":"CABLE HARNESS EMERGENCY HAMMER",
"ProductId":"01t0q0000023INwAAM"
}
]
let jsonString = JSON.stringify(this.temp);
        console.log('OUTPUT ::: ',jsonString);
        opportunityProductCreation({oppId : this.recordId, oliData : jsonString})
        .then(result=>{
            console.log(result);
            if(result){
                this.data = result;
            }
        }).catch(error => {
               this.data = undefined;
     });
I am new to the salesforce, anyone help is appreciated :D
Thank you.
: