• Roberto Nisti
  • NEWBIE
  • 35 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
When we try delete in 26 line (evtToCancel), this message show in log: "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Event.Subject"
 
public class CancelSchedule {
@InvocableMethod
        
    public static list<id> CancelSchedule(list<string> Ids){
        
        Try{
            Id OppId;
            for(string IDaux : ids){
                OppId = ID.valueOf(IDaux.left(15));
            }
            integer pos = 0;
            integer postocancel;
            integer postopernoite;
            event evtToCancel;
            Oportunidade_de_venda__c Opp = [select id, tw1_agendamento__c, tw1_terapeuta__c from Oportunidade_de_venda__c where id = :OppId];
            id terapeutaId = Opp.tw1_terapeuta__c;
            datetime agenda = Opp.TW1_Agendamento__c;
            date dataagenda = Opp.TW1_Agendamento__c.date();
            evtToCancel = [Select id, Subject, whatid, startdatetime from event where Ownerid = :terapeutaid and StartDateTime = :agenda and Subject = 'Visita' limit 1];
            event evtForCancel =  [Select id, Subject, whatid, startdatetime from event where id = :evtToCancel.Id]; 
            system.debug('Passei pelo primeiro evento');
            event[] evt = [Select id, whatid, startdatetime from event where Ownerid = :terapeutaid and DAY_ONLY(StartDateTime) = :dataagenda order by StartDateTime];
            for(event evtaux : evt){
                system.debug('Evento '+ evtaux.whatid);
                if(evtaux.id == evtToCancel.Id){
                     delete evtForCancel;
                }
                if(evtaux.Subject == 'Pernoite'){
                    CheckandFeed.recalculaprimeiro(dataagenda.addDays(1), terapeutaId);
                    delete evtaux;
                }
                pos++;
            }
            Opp.TW1_Agendamento__c = Null;
            Opp.TW1_Terapeuta__c = Null;
            Opp.TW1_Status_Agendamento__c = 'Pré-agendado';
            
            update Opp;
            List<ID> atdId = new List<ID>();
                atdId.add(Opp.Id);
    
    
                return atdId;
        } catch (DmlException e) {
            System.debug('A DML exception has occurred: ' + e.getMessage());
            return NUll;
        }
       
    }

}

 
I need take Opportunity Id from record on the screen, how can I get that?
I tried to get CurrentRecord from flow, but  it didn't work.

I did this flowI tried to get value from record from screenWhen I click in this button "Cancela Agendamento" the flow needs to get record id from this screen
Hi,

   I try to get geolocation when I click on button. I Try it:

{!REQUIRESCRIPT("/soap/ajax/44.0/connection.js")}

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function success(pos) {
  var crd = pos.coords;

   {!Contact.MailingLatitude} =  crd.latitude;
    {!Contact.MailingLongitude} = crd.longitude);
};

function error(err) {
  console.warn('ERROR(' + err.code + '): ' + err.message);
};

navigator.geolocation.getCurrentPosition(success, error, options);

But, when a check the syntax, show me this error:

<span class="errorStyle">Error: The Name field is required.</span>
I need to get geolocation from users when they click in a button, I saw some solutions but using javascript. 
My doubt is: are there one way to do it without javascript?

 
Hello,

I try instaciated a constructor as:


                 string address1 = CheckAndFeed.descricaoenderecouser(terapeutaId);
                string address2 = CheckAndFeed.descricaoendereco(accId);
                
                googlemaps gerarota = new googlemaps(address1, address2);


And my constructor is:

public class googleMaps {

    public String duration {get;set;}
    public Integer travelTime {get;set;}
    public Decimal distance {get;set;}
    
    public googleMaps (
            String address1,
            String address2) {
        
        system.debug('In google maps');
        String jsonResults = getJsonResults(address1, address2);
        system.debug('After Json');
...

It doesn't work, object isn't instatiated. I don't know why.
II did everything, did double check, but when I submit to verify, the chalenge is wrong: "Challenge Not yet complete... here's what's wrong: 
The initial submission action is not correct for the 'Discount Approval Process'. VP approval does not appear to be required for discounts over 40% for step #2 in the process."

But it's correct, as you can see in diagram:

User-added image
When we try delete in 26 line (evtToCancel), this message show in log: "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Event.Subject"
 
public class CancelSchedule {
@InvocableMethod
        
    public static list<id> CancelSchedule(list<string> Ids){
        
        Try{
            Id OppId;
            for(string IDaux : ids){
                OppId = ID.valueOf(IDaux.left(15));
            }
            integer pos = 0;
            integer postocancel;
            integer postopernoite;
            event evtToCancel;
            Oportunidade_de_venda__c Opp = [select id, tw1_agendamento__c, tw1_terapeuta__c from Oportunidade_de_venda__c where id = :OppId];
            id terapeutaId = Opp.tw1_terapeuta__c;
            datetime agenda = Opp.TW1_Agendamento__c;
            date dataagenda = Opp.TW1_Agendamento__c.date();
            evtToCancel = [Select id, Subject, whatid, startdatetime from event where Ownerid = :terapeutaid and StartDateTime = :agenda and Subject = 'Visita' limit 1];
            event evtForCancel =  [Select id, Subject, whatid, startdatetime from event where id = :evtToCancel.Id]; 
            system.debug('Passei pelo primeiro evento');
            event[] evt = [Select id, whatid, startdatetime from event where Ownerid = :terapeutaid and DAY_ONLY(StartDateTime) = :dataagenda order by StartDateTime];
            for(event evtaux : evt){
                system.debug('Evento '+ evtaux.whatid);
                if(evtaux.id == evtToCancel.Id){
                     delete evtForCancel;
                }
                if(evtaux.Subject == 'Pernoite'){
                    CheckandFeed.recalculaprimeiro(dataagenda.addDays(1), terapeutaId);
                    delete evtaux;
                }
                pos++;
            }
            Opp.TW1_Agendamento__c = Null;
            Opp.TW1_Terapeuta__c = Null;
            Opp.TW1_Status_Agendamento__c = 'Pré-agendado';
            
            update Opp;
            List<ID> atdId = new List<ID>();
                atdId.add(Opp.Id);
    
    
                return atdId;
        } catch (DmlException e) {
            System.debug('A DML exception has occurred: ' + e.getMessage());
            return NUll;
        }
       
    }

}

 
I need to get geolocation from users when they click in a button, I saw some solutions but using javascript. 
My doubt is: are there one way to do it without javascript?

 
II did everything, did double check, but when I submit to verify, the chalenge is wrong: "Challenge Not yet complete... here's what's wrong: 
The initial submission action is not correct for the 'Discount Approval Process'. VP approval does not appear to be required for discounts over 40% for step #2 in the process."

But it's correct, as you can see in diagram:

User-added image