• dj_0x7c0
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
(Lightning Experience) When session timeout warning popup appears two events occurs. 
First component event salesforceIdentity:sessionTimedOut and later app event force:logout and component. Both aren't available in Salesforce documentation or Component Library (Summer '18, API 43.0)
Despite of the fact I wanted to handle this with Lightning Component Framework via aura:handler.
<aura:handler event="force:logout" action="{!c.handleAction}"/>
OR
<aura:handler event="salesforceIdentity:sessionTimedOut" action="{!c.handleAction2}" phase="capture" />
If I want to save any handler, then save/deploy results in failing to save component:
Failed to save sample.cmp: An unexpected error occurred. Please include this ErrorId if you contact support: 8989761-99970 (356507915).

I checked this on three instances, and the same result. Do you have any information that such events won't be supported? Do you any ideas how to handle, detect session logout from frontend side?
Being aware that Visualforce.remoting.Manager is not available in LEx.
Hello
I'm processing flat structure object into two objects with relation, it's more complicated, but I want to show it simplified. I want to create mass of records with reference in a for loop. Issue is that Id of Account  is not populated in one transaction. To do this I would have to add insert in a loop (bad practice).

Account (one-to-many lookup relation) Marker__c sobject
public class MyProcessor implements Queueable{
	public void execute(QueueableContext context) {

		List<Stage_Object__c> counterparties = [SELECT Counterparty_Identifier__c, Full_Name__c, Processed__c
                                              	FROM Stage_Object__c
                            				   	WHERE Processed__c = false LIMIT 3300];
		List<Account> accList = new List<Account>();
		List<Marker__c> markerList = new List<Marker__c>();
		for (Stage_Object__c so : counterparties){
			Account na = new Account(Name = so.Full_Name__c);
			accList.add(na);
			Marker__c m = new Marker__c(Account_ref__c = na.Id,
										Identifier__c = so.Counterparty_Identifier__c);
			m.Account_ref__c = na.Id;
			markerList.add(m);
			so.Processed__c = true;
		}
		try {
			insert accList;
			insert markerList;
			update counterparties;
		} catch (DMLException de){
			//handling Exception
		}
	}
}

Relation is not created, as Account Id is not created in Force.com database. I want to omit many inserts in a loop. It's a process with many records so I don't want to meet the limits and write it efficient.

I tried even something like that:
Account na = new Account(Name = 'Salesforce');
Marker__c m = new Marker__c(Counterparty_Identifier__c = 'some test id',
                            Account_ref__r = na);
insert m;
ResultError: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, More than 1 field provided in an external foreign key reference in entity: Account: []
or
Marker__c m = new Marker__c(Identifier__c = 'some test id');
Account na = new Account(Name = 'Hollywood Inc.');
na.Marker_r = m;

insert na;
ResultError: Field is not writeable: Account.Marker_r

I tried also add them in one List<SObject> and insert in one transaction (two chunks), but reference also wasn't added.

Thanks for your ideas and thoughts,
DJ
Hello
I'm processing flat structure object into two objects with relation, it's more complicated, but I want to show it simplified. I want to create mass of records with reference in a for loop. Issue is that Id of Account  is not populated in one transaction. To do this I would have to add insert in a loop (bad practice).

Account (one-to-many lookup relation) Marker__c sobject
public class MyProcessor implements Queueable{
	public void execute(QueueableContext context) {

		List<Stage_Object__c> counterparties = [SELECT Counterparty_Identifier__c, Full_Name__c, Processed__c
                                              	FROM Stage_Object__c
                            				   	WHERE Processed__c = false LIMIT 3300];
		List<Account> accList = new List<Account>();
		List<Marker__c> markerList = new List<Marker__c>();
		for (Stage_Object__c so : counterparties){
			Account na = new Account(Name = so.Full_Name__c);
			accList.add(na);
			Marker__c m = new Marker__c(Account_ref__c = na.Id,
										Identifier__c = so.Counterparty_Identifier__c);
			m.Account_ref__c = na.Id;
			markerList.add(m);
			so.Processed__c = true;
		}
		try {
			insert accList;
			insert markerList;
			update counterparties;
		} catch (DMLException de){
			//handling Exception
		}
	}
}

Relation is not created, as Account Id is not created in Force.com database. I want to omit many inserts in a loop. It's a process with many records so I don't want to meet the limits and write it efficient.

I tried even something like that:
Account na = new Account(Name = 'Salesforce');
Marker__c m = new Marker__c(Counterparty_Identifier__c = 'some test id',
                            Account_ref__r = na);
insert m;
ResultError: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD, More than 1 field provided in an external foreign key reference in entity: Account: []
or
Marker__c m = new Marker__c(Identifier__c = 'some test id');
Account na = new Account(Name = 'Hollywood Inc.');
na.Marker_r = m;

insert na;
ResultError: Field is not writeable: Account.Marker_r

I tried also add them in one List<SObject> and insert in one transaction (two chunks), but reference also wasn't added.

Thanks for your ideas and thoughts,
DJ