Need help in trigger - triggers

Trigger whenever phone field is updated in account then the name field should also get updated with the same and phone number in accounts.
Trigger:
trigger ThirdTrigger on Account (after update) {
ThirdTriggerHandler.MyMethod(trigger.new);
}
Handler:
public class ThirdTriggerHandler {
public static void MyMethod(List<account> accList){
for(account acc:accList){
if(acc.phone!=trigger.oldMap.get(acc.id).phone){
acc.name=acc.name+acc.phone;
}
}
}
}
I am getting an error saying
Variable does not exist: phone

Related

Photon creating new room instead of connecting to already existing one?

When I create a build of the game, everything works normally. However, when the second player tries to connect to the room with the name, it says that the room does not exist and if I create a room with the first rooms name it gets created instead of saying "room already exists".
I thought it could be a region problem, but in PhotonServerSettings, the "Fixed Region" is set to "eu", "Use Name Server" checked on, and "Dev Region" set to null (left it empty). In the build settings I set "development build" to false.
I don't understand why the two games would not be in the same region based on what I mentioned before?
Picture of the PhotonServerSettings
This is the code for creating/joining a room:
public void CreateRoom()
{
if (string.IsNullOrEmpty(CreateInputField.text))
{
return;
}
PhotonNetwork.CreateRoom(CreateInputField.text);
}
public void JoinRoom()
{
if (string.IsNullOrEmpty(JoinInputField.text))
{
return;
}
PhotonNetwork.JoinRoom(JoinInputField.text);
}
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("Game");
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
failText.text = message;
}
public override void OnJoinRoomFailed(short returnCode, string message)
{
failText.text = message;
}
}
(for some reason I cant put the entire script but these are the important parts)

Inconsistency in cucumber execution

There are two inconsistencies in my execution.
1) As per the following scenario, "And Click Create Customer" annotation doesn't work correctly. I've updated it before instead of the expression included "#Then("Musteri Olustur tabina tikla ve acilan sayfada submit butonuna tikla")" and once i try to execute it by performing run as feature file with right click, somehow I'm still getting error about previous annotation (the one starting #Then).
2) Second issue is the sixth step of the scenario is not being executed at all. ("Then Type customer information")
How is this possible ?
First four step is working correctly.
Feature: Create Customer
Scenario: Create Prepaid Customer Turkish Citizen
Given Access to LegacyCRM
When Type your username and password
And Click login button
Then Verify that legacycrm is opened
And Click Create Customer
Then Type customer information
-
public class CucumberCustomer {
WebDriver driver;
#Given("^Access to LegacyCRM$")
public void AccessLCRM (){
File file = new File("C:/Users/wiprofkaymaz/Desktop/ie32/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver",file.getAbsolutePath());
driver = new InternetExplorerDriver();
driver.get("https://iccbcf/TelsimGlobal/Menu/showLogin.jsp");
}
#When("^Type your username and password$")
public void TypingLoginInformations(){
driver.findElement(By.xpath("//input[#name='username']")).sendKeys("wiprobaslan");
driver.findElement(By.xpath("//input[#type='password']")).sendKeys("Voda123456789**");
}
#And("^Click login button$")
public void ClickLoginButton(){
WebElement login=driver.findElement(By.xpath("//input[#src='/TelsimGlobal/Menu/image3.gif']"));
login.click();
}
#Then("^Verify that legacycrm is opened$")
public void legacycrmverification(){
driver.switchTo().frame("ax");
driver.switchTo().frame("menu");
boolean vry =driver.findElement(By.xpath("//img[#src='images/vodafone_logo_top.gif']")).isDisplayed();
if(vry){
System.out.println("application has been opened");
}
else{
System.out.println("something wrong");
}
}
#And("^Click Create Customer$")
public void Customercreatev1(){
driver.findElement(By.xpath("//a[#title='Müşteri Oluşturma']")).click();
driver.switchTo().defaultContent();
driver.switchTo().frame("cx");
driver.findElement(By.xpath("//input[#name='Submit']")).click();
}
#Then("^Type customer information$")
public void Customercreatev2() throws InterruptedException{
driver.switchTo().defaultContent();
driver.switchTo().frame("cx");
driver.findElement(By.xpath("//input[#name='name']")).sendKeys("KEM");
driver.findElement(By.xpath("//input[#name='lastname']")).sendKeys("KEM");
Select selectObject = new Select (driver.findElement(By.xpath("//select[#name='day']")));
selectObject.selectByValue("10");
Thread.sleep(1000);
Select selectObject2 = new Select (driver.findElement(By.xpath("//select[#name='month']")));
selectObject2.selectByValue("10");
Thread.sleep(1000);
Select selectObject3 = new Select (driver.findElement(By.xpath("//select[#name='year']")));
selectObject3.selectByValue("1950");
Thread.sleep(1000);
String mainWindow = driver.getWindowHandle();
driver.findElement(By.xpath("//input[#name='iddistrict']")).sendKeys("ADANA");
driver.findElement(By.xpath("//input[#name='fathername']")).sendKeys("BABA");
driver.findElement(By.xpath("//input[#name='Submit']")).click();
Windows(driver, mainWindow);
driver.switchTo().window(mainWindow);
}
public void Windows (WebDriver driver, String mainWindow) {
mainWindow = driver.getWindowHandle();
Set<String> totalwindowsIds = driver.getWindowHandles();
int a=0;
String[] myset = totalwindowsIds.toArray(new String[totalwindowsIds.size()]);
if(myset[a].contains(mainWindow)){
driver.switchTo().window(myset[a+1]);
}
else{
driver.switchTo().window(myset[a]);
}
}
}

Laravel 5.3 : eager load with many to many relationship

I'm trying to use eloquent to retrieve 5 last messages and display them on the dashboard.
The problem is, I need to get those messages depending on the user->role. But the message is linked to an update log. This update log is use to dispatch every dashboard message, sms to notify and email.
There is how it work :
User
public function role()
{
return $this->belongsTo(Role::class);
}
Role
public function updatelogs()
{
return $this->belongsToMany(Updatelog::class, 'role_updatelog');
}
public function users()
{
return $this->hasMany(User::class);
}
Updatelog
public function roles()
{
return $this->belongsToMany(Role::class, 'role_updatelog');
}
public function dashboard_message()
{
return $this->hasOne(DashboardMessage::class);
}
DashboardMessage
public function updatelog()
{
return $this->belongsTo(Updatelog::class);
}
There is what I tried:
$dashmessages = DashboardMessage::with(array('updatelog' => function($q) use($user) {
$q->with(array('roles' => function($q2) use($user) {
$q2->whereHas($user->role_id);
}));
$q->whereHas('institution');
}))->with('updatelog.institution.rate_grids')->orderBy('updated_at', 'DESC')->take(5)->get();
I'm getting the last 5 DashboardMessages without the role constraint. What am I doing wrong?
EDIT---------------------------------------------------
I just tried something else and it work perfectly:
$updatelog = Updatelog::whereHas('roles', function ($query) use($user) {
$query->where('role_id', $user->role_id);
})
->whereHas('dashboard_message')
->with('dashboard_message')
->whereHas('institution')
->with('institution')
->with('rate_grid')
->take(5)->get();

Test class for Apex Trigger

I am new in Apex Development.
I want to write a TestClass for my Apex Trigger.
I am sharing my code with you.
trigger UpdateContact on Account (after Insert) {
List <Contact> contactList=new List<Contact>();
for(Account a:Trigger.new)
{
Contact c=new Contact(LastName=a.Name, AccountId=a.id);
contactList.add(c);
}
insert contactList;
}
Since your trigger in on Account (after insert), provided that there is no other mandatory field or validation rule, just simply insert an account to test your trigger:
#isTest
private class UpdateContactTest
{
static testMethod void myUnitTest()
{
Account acc = new Account(
Name = 'Test');
insert acc;
}
}

Workflow with id "xxxxx" not found in state persistence store

I have a workflow application which throws error when i try to invoke a event using ExternalDataExchangeService.
Workflow with id "866568ab-ca1b-4404-a2f1-2c8704539ef4" not found in state persistence store.
Event "QAEngOrTLReject" on interface type "RecipeChangeService.IRecipeChangeService" for instance id "866568ab-ca1b-4404-a2f1-2c8704539ef4" cannot be delivered.
Here is my implementation code for it - Please help I am stuck :(
Below is the interface and data exchange event args -
public class RecipeChangeService : IRecipeChangeService{
#region IRecipeChangeService Members
public event EventHandler QAEngOrTLApprove;
public event EventHandler QAEngOrTLReject;
public bool QAEngOrTLApproved(Guid instanceId, ResponseDataObject rdo) {
if (QAEngOrTLApprove != null) {
QAEngOrTLApprove(this, new XMESWFRecipeResponseDataEventArgs(rdo, instanceId));
return true;
}return false;
}
public bool QAEngOrTLRejected(Guid instanceId, ResponseDataObject rdo) {
if (QAEngOrTLReject != null) {
QAEngOrTLReject(this, new XMESWFRecipeResponseDataEventArgs(rdo,instanceId));
return true;
} return false;
}
}
[Serializable]
public class XMESWFRecipeResponseDataEventArgs : ExternalDataEventArgs {
public readonly ResponseDataObject rdo = null;
public XMESWFRecipeResponseDataEventArgs(ResponseDataObject rdo, Guid instanceId)
: base(instanceId)
{
this.rdo = rdo;
}
}
The event is raised using -
IRecipeChangeService s =
ExceptionServices.GetExceptionService(WorkflowExceptionType.RecipeChange)
as IRecipeChangeService;
s.QAEngOrTLApproved(new Guid(instanceId), rdo);
Thanks .
Do us a favour and please make sure the code is readable.
There can be a number of reasons the workflow cannot be found. First of all you will also see this error if there is no persistence service and the workflow isn't in memory. Another thing to check is if the workflow hasn't completed yet. This can be either as the result of some other event or because of an unhandled error.