getting Modified and Created Field value
- Hatice Togrul Gürol
- Posts: 24
- Joined: Thu Nov 13, 2014
hi Dmitry,
I need created and Modified field value.
ı found a code block that you mentioned. But this code returns only Editor and Author field values.
İs it possible to get date field value with the same code.
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(parseInt(GetUrlKeyValue('ID')));
ctx.load(item);
ctx.executeQueryAsync(function() {
alert('Author: ' +
item.get_item('Author').get_lookupId() +
' - ' +
item.get_item('Author').get_lookupValue() +
'\nEditor: ' +
item.get_item('Editor').get_lookupId() +
' - ' +
item.get_item('Editor').get_lookupValue());
});
}), "SP.js");
I need created and Modified field value.
ı found a code block that you mentioned. But this code returns only Editor and Author field values.
İs it possible to get date field value with the same code.
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(parseInt(GetUrlKeyValue('ID')));
ctx.load(item);
ctx.executeQueryAsync(function() {
alert('Author: ' +
item.get_item('Author').get_lookupId() +
' - ' +
item.get_item('Author').get_lookupValue() +
'\nEditor: ' +
item.get_item('Editor').get_lookupId() +
' - ' +
item.get_item('Editor').get_lookupValue());
});
}), "SP.js");
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Please, use the following code:
If you need to output these values on the form, you can put a plain text control with the following content instead:
Created: [Created]
Modified: [Modified]
Please, use the following code:
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(parseInt(GetUrlKeyValue('ID')));
ctx.load(item);
ctx.executeQueryAsync(function() {
alert('Modified: ' +
item.get_item('Modified') +
'\nCreated: ' +
item.get_item('Created'));
});
}), "SP.js");
Created: [Created]
Modified: [Modified]
- Hatice Togrul Gürol
- Posts: 24
- Joined: Thu Nov 13, 2014
I have added the code that you mentioned but alert shows not a good date format .
the screen like this;
Modifed: Mon nov 17 13:40:46 UTC +0200 2014
I want to show like this date format;
Created at 17.11.2014 13:40
Last Modified at 17.11.2014 13:40
I don't want to use default [Created] or [Modified] field.
I need to assign my own to a field that is using this codes.
the screen like this;
Modifed: Mon nov 17 13:40:46 UTC +0200 2014
I want to show like this date format;
Created at 17.11.2014 13:40
Last Modified at 17.11.2014 13:40
I don't want to use default [Created] or [Modified] field.
I need to assign my own to a field that is using this codes.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
You can use additional JavaScript library to format date objects, e.g datejs, date.format. With datejs your code will look something like that:
You can use additional JavaScript library to format date objects, e.g datejs, date.format. With datejs your code will look something like that:
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var list = ctx.get_web().get_lists().getById(_spPageContextInfo.pageListId);
var item = list.getItemById(parseInt(GetUrlKeyValue('ID')));
ctx.load(item);
ctx.executeQueryAsync(function() {
alert('Modified: ' +
item.get_item('Modified').toString('dd.MM.yyyy HH:mm') +
'\nCreated: ' +
item.get_item('Created').toString('dd.MM.yyyy HH:mm'));
});
}), "SP.js");
-
- Information
-
Who is online
Users browsing this forum: No registered users and 14 guests