xAPI verb not showing in the ADL Public statement viewer - tin-can-api

This is part of the last question that I posted. The code below sends the statement but when I view the record in the ADL statement viewer the verb is not showing. Can you tell me what I might be doing wrong on the verb line? Thank you.
function init()
{
var stmt = new ADL.XAPIStatement(
'mailto:menken.john#gmail.com',
'http://adlnet.gov/expapi/verbs/launched',
'http://vwf.adlnet.gov/xapi/virtual_world_sandbox'
);
ADL.XAPIWrapper.changeConfig({
'endpoint': 'https://lrs.adlnet.gov/xapi/',
'user': 'xapi-tools',
'password': 'xapi-tools',
'auth': 'xapi-tools'
});
ADL.XAPIWrapper.sendStatement(stmt);
}

Your verb object does not contain a display property including a human readable version of the verb (which is not required so your statement is valid), the ADL statement viewer doesn't appear to have a fallback (such as to the id).

Related

Followed different suggestions but still get "Invalid hook call. Hooks can only be called inside of the body of a function component"

I'm getting
Error: Invalid hook call. Hooks can only be called inside of the body
of a function component.
I followed different suggestions here on other questions and also on other forums. The last I tried is this one, but still I can't figure out what's the problem with my code:
function myFunc() {
const locale = useSelector((state) => state.locale);
return <></>;
}
I am really new to react so don't hesistate to tell me if you need me to post further details

how to use the expand parameter in Xrm.WebApi.retrieveRecord

I am using below scripts to get the reference entity from email entity. When the scripts was triggered, it prompts 'Could not find a property named 'new_queue' on type 'Microsoft.Dynamics.CRM.email''.
The reference entity's scheme name is new_queue, and I think the structure of the script is same as the guidance of microsoft knowledge article.
(https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrieverecord)
Can anybody point out what's wrong here?
Xrm.WebApi.retrieveRecord("email", '4884f79f-42f3-ea11-a815-000d3a44afcc', "?$select=subject&$expand=new_queue($select=queueid,name)").then(
function success(result) {
var toLookup = new Array();
toLookup[0] = new Object();
toLookup[0].id = result.queueid;
toLookup[0].entityType = "queue";
toLookup[0].name = result.name;
alert(result.name);
}, function (error) {
Xrm.Utility.alertDialog(error.message);
});
This issue is usually an outcome of case sensitive schema name, try new_Queue instead of new_queue. You can always verify this by checking in xml metadata.
Update:
I remember that the activity (email, task, appointment, etc) is special and little different. Make sure you download the metadata xml from Developer resources and check the correct navigation property. It should look like email_new_queue or new_queue_email
To know the correct navigation property name to use it in $expand:
Request the "Email" entity and Include the following header Prefer: odata.include-annotations="*".
In the response, you should find a field that looks something like:
"_new_queue_value#Microsoft.Dynamics.CRM.associatednavigationproperty": "????"
Use the name you'll find in the place of "????" in the $expand expression.

New to Servicenow Script

I have a custom field in Incident table called 'u_custom_long_description' In UI policy i have written a script to check if the field is empty or not at the time of closing the incident.
function onCondition() {
if(current.u_custom_long_description == null){
alert('Please provide the description for the close comments');
}
}
and I am getting the following error when i close the incident
onChange script error: ReferenceError: current is not defined function
(){var o=i(m,arguments);return l.apply(n,o)}
You are in a client-side script where the server-side variable current does not exist. To get the value of a field on the form, you can use g_form:
function onCondition() {
if(g_form.getValue('u_custom_long_description') == ''){
alert('Please provide the description for the close comments');
}
}
Also, alert is so 90s! You'd make for a better experience by using something like showFieldMsg. Take a look at this section in the docs about validating field input client side which has an example similar to what you're trying:
https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/script/client-scripts/concept/client-script-best-practices.html#ariaid-title6

Finding object in array initial state React-Redux app

I am currently working on an app that do not support server rendering, so i have to have an empty state when the client loads the app. Then a fetch is dispatched and the state is soon updated.
I have a component (some kind of editor) which should find an object based on a url-parameter. My mapStateToProps function looks something like this:
const mapStateToProps = (state, ownProps) => {
return {
book: state.library.list.find(function(book){ return book.id === ownProps.params.book_id})
}
}
this.props.book is undefined when the component runs getInitialState, so it does not get the update when the state is fetched. I get the following error in the console of my browser when the component loads:
TypeError: undefined is not an object (evaluating 'this.props.book.title')
From there on the editor remains empty, even when the state is received from the server later on.
Any idea of how i can solve this problem?
What you need to do is put a watch when you are loading data from this.props.book to not be an undefined
if(this.props.book) {
//do something with this.props.book
}
Solution: Preload the store on the server
I finally found an answer to my problem. What i did, was to check upon every request if the user was logged in (through JSON web tokens). If the user was logged in, i preloaded the state and sent it with the first request (assigned it to window._PRELOADED_STATE_ with a script tag in the response string).
Then i also added two lines on the client code
const preloadedState = window.__PRELOADED_STATE__
const store = createStore( rootReducer, preloadedState, applyMiddleware(apiMiddleware, thunkMiddleware) );
then the store was updated before the editor component asked for it.
This solution is based on some ideas introduced at redux's home page http://redux.js.org/docs/recipes/ServerRendering.html

laravel 4.2. user permissions and hiding link source

I am a total newbie with Laravel and learning it now for a week. I have some basic questions that I can't find an answer to. Next week I will start with developing CRM system and I need some info from experienced developers who could tell me is the approach I am attending to make a good one.
I will need some authentication system, like 4 groups of users (Admin, Basic, Manager, Office) where Manager and Admin will add the Basic users. There will be few view and features and every groups will have defined access to each view and feature. Since few days I am searching for packages, watching the tutorials and learning. I found an interesting package for which I think it could help me with this user-group-permission things.The package is Sentry. Could this help me with my requirements?
What is the case when for example I have a user in group Basic and he deletes for example some comment with the button. On the left side down in the browser the user can see the link to this comment when he hovers the link. For example www.test.com/comments/345/delete where the id is 345. What if user types that with another id, that means he can delete another comment. I found some suggestions on how to solve this, to make it with jQuery and javascript so the link wouldn't be shown and POST would be made with for example with AJAX. But since I am a newbie, I am thinking how much time would this take and is this a good approach at all? Could package Sentry from 1. question help me with the permission on what route each group can access?
Any help or advice would be appreciated.
Sentry does what you want, yes. Here's a question with some answers explaining the permissions part.
The visible link part can be avoided by doing a POST request instead of a GET request.
When you open your form, you add a method attribute.
Form::open(array('url' => 'foo/bar', 'method' => 'post'))
A GET request will put the parameters in the URL, hence the visible ID. Using a POST request will put the parameters in the headers, thus hiding it from the URL.
An example could be deleting a comment. A GET request could look like this:
http://www.example.com/comments/delete/1
And the parameters would be defined in your method signature:
public function getDelete ($id) {
Comment::find($id)->delete();
}
Where the POST equivalent would be
http://www.example.com/comments/delete
And the parameters would be defined in your Input class, you would get them using the get method
public function postDelete() {
Comment::find(Input::get('id'))->delete();
}
1) The best package to help you with that is Sentry indeed.
2) To make sure an user can delete only his comments you can do something like this (but there are more solutions either you do it with Ajax or not):
public function destroy($id) {
$user = Sentry::getUser();
$comment = Comment::find($id);
if($comment) {
if($comment->user_id != $user->id) {
return Response::back(); // optional message: Permission denied!
}
$comment->delete();
return Response::back(); // optional with message: Deleted!
}
return Response::back(); // optional message: Comment not found!
}
You can use Sentry in this case to get the logged in user and check for user id. I think you should let user delete their own comments always but if you need special roles (Admins for example) to be able to delete any comment, or special permission comments.delete (For some Managers) - you can use Sentry as well:
public function destroy($id) {
$user = Sentry::getUser();
$comment = Comment::find($id);
if($comment) {
if($comment->user_id != $user->id && !$user->hasRole('Admin') && !$user->hasPermission('comments.delete'))) {
return Response::back(); // optional message: Permission denied!
}
$comment->delete();
return Response::back(); // optional with message: Deleted!
}
return Response::back(); // optional message: Comment not found!
}
A nicer way of making the DELETE thru a Form request check this:
Laravel RESTfull deleting

Resources