Ok. If you didnt spell a full name right, and only entered the lastname, and the there exist more users with that lastname, in the recipient field, the ajax call will return an error with
Who did you mean: Mami Fox Megan Fox Blabla Fox
Now, I would like to make so you can click on them, choose who you meant to send to.
To do this I cannot use confirm, as confirm only have OK/CANCEL.
So i got told to use jQuery BlockUI Plugin, or just making a div and show().
But how can I prepend the error in a div(i know this), show it(i know this), and then make so you are able to click on them, and receive a alert on click ('you have chosen Mami Fox').
As i cannot make an prepared div with the names in(as the name are suggested from the page ajax requested, sendPM.php), and so, I would like to know how to do this.
--
Firstly i guess i would need to make json variable for each name. e.g
name1 : 'Mami Fox', name2 : 'Megan Fox', name3: 'Blabla Fox'
So in the div you can then prepend the names in there(instead of one variable with all names including "Who did you mean"), and make them so when you click on them, it will say "You have chosen"+data.name1 (example, where data is callback function name from the ajax success)..
--Just a thought.
You're going to have to create a workflow that supports the process that you want. This means using a flowchart or something. You can't just code the solution, you have to design it. http://en.wikipedia.org/wiki/Workflow
So the user selects a last name, but more than one last name exists.
BRANCH WORKFLOW FROM "STANDARD"
Build a list of all possible choices.
Present the user with a dialog to choose the appropriate name from the given list.
User selects a name.
RESUME WORKFLOW TO "STANDARD"
Related
Is there any possibility to call inside a scenario another scenario using tags?
How to encapsulate some cucumber steps in one step? or in a parameter? or in tag?
Eq.
#payload_car
Scenario: Populate Car payload
Given the user "x" populate the car payload
When the following information about car are introduced: type "Tesla", color "red", length "4.5m"
Then the Payload Car is populated
#car
Scenario: Select car
Given the user "y" is logged
When the user select the car "Tesla"
And populate the payload car #payload_car
Then the selected car contains all the details
Is it possible to call the scenario #payload_car when the #car scenario is called?
I mention that the scenario above is fictiv just to be more explicit...
Assuming you'd want to reuse those steps/scenarios:
you might be able to achieve the desired behaviour by doing the following:
You can pull the common behaviour in a Background (https://cucumber.io/docs/gherkin/reference/#background) (like the login)
And then leverage the capability of Scenario outlines (https://cucumber.io/docs/gherkin/reference/#scenario-outline), to test every combination that would lead to your Then steps.
But maybe I'm assuming wrong, can you give us a little more details about what you're trying to achieve?
No, you cannot call a scenario from another scenario.
So i've been asked to remake some registration forms. The way its supposed to work is, that an interpreter chooses X amount of languages in the first select box. Then based on the selections of languages, the user must specify from which languages they can translate from/to.
I want to store this data in a key/value array, with the key being "LanguageFrom" and Value being another array, of "LanguagesTo". This is how i have solved this:
function btnTest() {
var fromArray = $('.freelancerLanguagesFrom').map(function() {
return $(this).val();
}).get();
var toArray = $('.freelancerLanguagesTo').map(function() {
return $(this).val();
}).get();
var tempArray = {};
tempArray[fromArray] = toArray;
}
This method is being called with an "onclick" function in the html part. The user should specify which languages he can translate to for each of the chosen languages in the first box,
I am aware that this probably isn't the ideal approach, but im still an inexperienced developer, and i'd love to hear your take on another approach.
Now comes my problem:
1) How do i make it so the array wont overwrite the existing array with each button click, and instead just add to the array?
2) How do i process this array on the server side (php), so that i can store the values in my database?
3) Is it possible to skip the flow where the user has to press the save(gem) button after each language he has chosen?
edit: Question 1 and 3 are now solved, my only problem is accessing the array i made in js, on the php side
1) tempArray exists only in the scope of the btnTest() function. Declare it outside (in the global scope), initialize it as {} and don't reset it every time you click the button. The way you get the fromArray variable may require some tweaking depending on whether the "from" list can accept a multiple selection or not.
2) Ajax may help. Create a php endpoint to receive the request and call it using ajax. You can work on the array using JSON. Send your data using JSON.stringify(tempArray) and read it using json_decode() in your php script, or simply set the request headers as "application/json" to have it done automatically for you.
3) I personally wouldn't automate this process. Let's say I have 4 languages, Italian, English, French and Chinese.
I have selected a desirable state of languages I can handle:
Italian -> English, French
But I also know how to translate French in Italian so I click, in the from list, French, and I get
French -> English
Which is an undesirable state, for me, because I don't know how to do that. Especially if I were to select many languages, I'd get, inbetween 2 states I want to save, an indefinite amount of states I don't want to save.
If you still want to do so, you need to move the even listener from the button to the list(s), with the onchange event.
I'd also suggest you do your event binding trough jQuery, if you aren't already.
Hope this helped.
I am trying to navigate to another tab shown in the html code below from my current tab in VBA.
<div title="0274 AP INVOICES SAP" data-bind="text: Name, attr: { title: Name }">0274 AP INVOICES SAP</div>
I tried the following:
ie.document.querySelector("[title*=AP INVOICES SAP].menu-row active-route").Click
but this gave me the "Method 'querySelector' of object 'JScriptTypeInfo' failed" error, and I also tried the following:
ie.document.querySelector("div[data-bind*='0274 AP INVOICES SAP']").Click
but this gave me the "Object required" error.
What should I do to navigate to this tab properly? Please let me know if you need more information
You have half the answer (syntax wise) in each of your two lines.
You need
ie.document.querySelector("[title='0274 AP INVOICES SAP']").click
Assuming a proper page load wait has happened before and that this title = value combination is either unique and/or you want the first; that it is not dynamic and that it is the correct target for the click event.
Due to the spaces in the value string you need to use single quotes around the it. Also, after the attribute selector you should not be using class selectors which aren't part of the target element.
If you continue to get a JScriptTypeInfo error, which I have seen before with pages using knockoutjs, you need to either resort to MS ScriptControl and a lot more code (on a 32 bit system) - which I don't recommend, or switch to using a getElement(s) by method where this problem shouldn't occur. You are ending up with an array like object that VBA is calling JSCriptTypeInfo and if you inspect it you will mostly likely see a string denoting an array of objects (nodes) which come, I suspect, from a default member call.
It is easy to remove an option from an option set.
var control = Xrm.Page.ui.controls.get("casetypecode");
control.removeOption(1);
But, when you try to remove a subject from a subject field, it does not work.
This is the type:
This is how it looks when expanded:
Can anybody help about this?
I just don't think that removeOption is going to work the subject field, it isn't an option set field - based on your image it is listed as a lookup.
Given that subject is a special field, I'm not sure which options are open to you. If it behaves like a normal lookup you might be able to use the lookup functions to filter the view.
Lookup control methods
Ok, so I have a kind of weird problem that I need ideas on how to solve.
I have a vb.net web application that points to a sql database. There's a table with a primary key that is an auto-incremented integer.
When a user adds an object to this table, it doesn't currently check to see if the "First Name" and "Last Name" already exist in one of the datarows. The desired addition to the functionality is as follows:
1)When the user submits the form, check the table to see if such a record already exists.
1.1)If the record doesn't exist proceed with the insert.
2)If that record does exist, display a warning to the user that such a record exists
2.1)The warning should have two buttons, "Continue" and "Cancel"
2.1.1)If the user clicks "Continue" go ahead and add the duplicate record
2.1.2)If the user clicks "Cancel" stop the insert.
I'm still relatively new to web development (a little over a year of experience). I am looking for the "correct" way to do this. The aspect of this task that is making it hard for me is that I have to run the query, and then possibly display and alert (javascript probably). I'm not sure how to display an alert in the middle of the server side validation.
Any ideas or comments are appreciated!
Thanks!
If you wouldn't allow insertion of duplicates, you could just create unique index in your database. However, what you can do now is to get the count of records in the database, where firstname and lastname equals to inserted.
In case of normal SQL it would look like
SELECT COUNT(recordID) WHERE firstName = #firstName AND lastName = #lastName;
Or it could look even easier with Entity Framework. Anyway, your question was about "displaying alert in the middle of server side validation". Think about it differently. Think about it as about two checks.
Add another control to your input form, an invisible checkbox near the Submit button. It should contain the expression about user's agreement to insert duplicate record.
Once you detect, that record is duplicate, interrupt the validation, and make checkbox visible, but Submit button - disabled. When user checks the checkbox, Submit button should become visible again.
Now, since you are going through the same validation again, you have to take your checkbox into equation - if it is visible and checked, you don't have to check for record duplication anymore, and just submit the record. If you need to re-use that input form, don't forget to uncheck the checkbox and make it invisible once again.
What you want to do here is add a confirm parameter or something like that to your method, like this:
' This is just pseudocode; I'm guessing you can translate it to
' whatever web framework you're using
Sub InsertRecord(ByVal name() As String, Optional ByVal confirm As Boolean = False)
If DuplicateRecord(name) And Not confirm
' Here's where you would render the page with a confirmation dialog
RenderViewToRequestConfirmation()
Return
End
DoInsertRecord(name)
RenderViewAfterRecordInserted()
End
Then under normal circumstances, from your front end you would submit a request that would call this method without the confirm parameter. In the case of duplicate records, the server would render a response with a dialog requesting confirmation. If the user clicked 'Yes' (or whatever), then the front end would send the same request but this time with the necessary request params to set confirm to True.
In terms of web requests, this process might look like:
| Request Data | Response |
|------------------------------------------|------------------------|
| { "name": "M Webster" } | Page w/ confirm dialog |
| { "name": "M Webster", "confirm": true } | Success page |
The route that I went is a little confusing... even now that I have it working, but i'll explain it here in case it makes sense to someone else who can better explain it later.
I wrote a function in the code behind that calls the function that checks the database for a duplicate record, but I added these two lines of code above the function declaration:
<System.Web.Services.WebMethod()>
<System.Web.Script.Services.ScriptMethod()>
Then, I wrote a JavaScript function that grabs the value from the Textbox and passes the value to that function in the code behind. This is made possible by those two lines above the function declaration in the code behind and by using the PageMethods object. The actual call from the JavaScript would look like this:
PageMethods.FunctionName(parameter, function(returnValueFromOtherFunction){
....function stuff
});
Then I assigned the JavaScript function to the onBlur event in the Textbox.
Thanks for the help guys, but I think this is the best way to solve my problem.